默认情况下在代码镜像中启动全屏
launch full screen by default in code mirror
我想在加载页面时默认启动代码镜像的全屏模式。我安装了插件,F11按键功能运行良好。但是,有没有一个Javascript函数我可以在页面上调用,这样编辑器就可以在全屏模式下打开,而无需用户将光标放在文本区域,然后按下其中一个映射键?
谢谢。
实际上这比你想象的要容易。您不必调用在示例中映射到F11的函数。如果你只在全屏中使用它就足够了,你只需要将css更改为:
style="padding: 1px; position: absolute; margin: 0px; left: 0px; right: 0px; top: 0px; bottom: 0px; width: auto; height: auto; "
这是一个完全有效的例子(就像http://codemirror.net/demo/fullscreen.html但仅全屏):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel=stylesheet href="//codemirror.net/doc/docs.css">
<link rel=stylesheet href="//codemirror.net/lib/codemirror.css">
<link rel=stylesheet href="//codemirror.net/theme/night.css">
<script src="//codemirror.net/lib/codemirror.js"></script>
<script src="//codemirror.net/mode/htmlmixed/htmlmixed.js"></script>
<script src="//codemirror.net/mode/xml/xml.js"></script>
<style type=text/css>
.CodeMirror {float: left; width: 100%; height: 100%; }
</style>
</head>
<body>
<div style="padding: 1px; position: absolute; margin: 0px; left: 0px; right: 0px; top: 0px; bottom: 0px; width: auto; height: auto; ">
<textarea id="content" name="content" style="display: none;"><dl>
<dt id="option_indentWithTabs"><code><strong>indentWithTabs</strong>: boolean</code></dt>
<dd>Whether, when indenting, the first N*<code>tabSize</code>
spaces should be replaced by N tabs. Default is false.</dd>
<dt id="option_electricChars"><code><strong>electricChars</strong>: boolean</code></dt>
<dd>Configures whether the editor should re-indent the current
line when a character is typed that might change its proper
indentation (only works if the mode supports indentation).
Default is true.</dd>
<dt id="option_specialChars"><code><strong>specialChars</strong>: RegExp</code></dt>
<dd>A regular expression used to determine which characters
should be replaced by a
special <a href="#option_specialCharPlaceholder">placeholder</a>.
Mostly useful for non-printing special characters. The default
is <code>/['u0000-'u0019'u00ad'u200b'u2028'u2029'ufeff]/</code>.</dd>
<dt id="option_specialCharPlaceholder"><code><strong>specialCharPlaceholder</strong>: function(char) → Element</code></dt>
<dd>A function that, given a special character identified by
the <a href="#option_specialChars"><code>specialChars</code></a>
option, produces a DOM node that is used to represent the
character. By default, a red dot (<span style="color: red">•</span>)
is shown, with a title tooltip to indicate the character code.</dd>
<dt id="option_rtlMoveVisually"><code><strong>rtlMoveVisually</strong>: boolean</code></dt>
<dd>Determines whether horizontal cursor movement through
right-to-left (Arabic, Hebrew) text is visual (pressing the left
arrow moves the cursor left) or logical (pressing the left arrow
moves to the next lower index in the string, which is visually
right in right-to-left text). The default is <code>false</code>
on Windows, and <code>true</code> on other platforms.</dd>
</dl>
</textarea>
</div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById('content'), {
mode: 'application/xml',
lineNumbers: true,
theme: "night"
});
</script>
</body>
</html>
只有一行:
editor.setSize(window.screen.width,window.screen.height);
相关文章:
- IE中的CSS翻转动画:翻转的一面显示镜像内容
- Markdown模式代码镜像正在创建
- 更改代码镜像中TextArea的高度和宽度
- IE中的CSS翻转动画:翻转的一面显示镜像内容
- 什么CSS/JS技巧驱动镜像反转http://com.google愚人节页面
- jquery使2组单选按钮相互镜像
- Nodejs使用httpdispatcher提供静态镜像
- HTML5相机缓冲和延迟(延迟镜像)
- jQuery插件在本地主机上运行良好,但在web服务器上却与bg镜像混淆
- 镜像滚动效果打开.在两个容器之间单击
- 代码镜像批量更改
- 如何在代码镜像编辑器中设置隐藏值
- Selenium-使用换行符将文件写入代码镜像
- 默认情况下在代码镜像中启动全屏
- 如何在代码镜像编辑器中设置不同的维度
- 将变量中的文本放入代码镜像文本区域
- 多种模式代码镜像
- 如何在 Angular2 组件中访问代码镜像文本区域值
- 如何使用 NPM 镜像
- 使用 .on() 高效镜像值