コードミラーで Web ページ全体を編集することは可能ですか?
getElementById('editor') を使用してから作成する代わりに<div id="editor"></div>
index.php があり、ページの下部にコード ミラーを追加し、コード ミラーを使用してページ全体を編集したいと考えています。テキストは私のウェブページを更新します。
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Editing the whole web page</title>
<base href="/">
<meta name="description" content="descritption here" />
<meta name="keywords" content="keyword1, keyword2, keyword3" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="" />
<link rel="stylesheet" href="../lib/CodeMirror/lib/codemirror.css">
<link rel="stylesheet" href="../lib/CodeMirror/theme/monokai.css">
<script src="../lib/jquery/jquery.js"></script>
<script src="../lib/jquery-ui/jquery-ui.js"></script>
<link rel="canonical" href="/" />
<style type="text/css" media="screen">
.CodeMirror {font-size: 16px; z-index: 999999999;}
</style>
</head>
<body>
<h1>Hello world!</h1>
<p> some text on my page </p>
<script src="../lib/CodeMirror/lib/codemirror.js" ></script>
<script src="../lib/CodeMirror/mode/xml/xml.js" ></script>
<script src="../lib/CodeMirror/mode/javascript/javascript.js" ></script>
<script src="../lib/CodeMirror/mode/css/css.js" ></script>
<script src="../lib/CodeMirror/mode/vbscript/vbscript.js" ></script>
<script src="../lib/CodeMirror/mode/htmlmixed/htmlmixed.js" ></script>
<script type="text/javascript">
var config, editor;
config = {
lineNumbers: true,
mode : "xml",
htmlMode: true,
theme: "monokai",
tabMode: "indent",
matchBrackets: true,
indentWithTabs: true,
readOnly: false
};
// the below only retrieves the get element by id :/
//editor = CodeMirror.fromTextArea(document.getElementById(""), config);
function selectTheme() {
editor.setOption("theme", "monokai");
}
setTimeout(selectTheme, 5000);
</script>
</body>
</html>
ありがとう、ミシェル