codemirror

CodeMirror has content but won't display until keypress

笑着哭i 提交于 2019-12-09 03:01:10
问题 I have a CodeMirror instance embedded in a webapp I'm building. It works great - except that the initial content won't display until user enters a new character. So it is all there but hidden until the user forces a change. This is bad. Is there any way I can force a repaint or refresh of the browser of simulate a character enter - whitespace will do. Here is the code... <textarea id='code-mirror' ><?php echo $contents; ?></textarea> <script> jQuery(document).ready(function(){ var textarea =

Copy and paste in codemirror.js embeded in javafx application

谁都会走 提交于 2019-12-09 01:07:10
问题 I'm creating simple editor in Java FX using codemirror.js library. I embeded codemirror editor in javafx using javafx.scene.web.WebView component, with the folowing html/js code: <body> <form> <textarea id="code" name="code"> </textarea> </form> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true}); </script> </body> Codemirror editor itself supports undo, redo, cut, copy and paste. I have also javafx main menue in my application and I want to

Downloading and Uploading in CodeMirror Textarea and Skulpt Execution Issues

房东的猫 提交于 2019-12-08 15:17:04
问题 This question has moved to Skulpt and CodeMirror Issues because the answers I had did not answer the question. 回答1: Here is the code snippet var delay; // Initialize CodeMirror editor var editor = CodeMirror.fromTextArea(document.getElementById('code'), { mode: { name: "python", version: 2, singleLineStringErrors: false }, tabMode: 'indent', lineNumbers: true, lineWrapping: true, autoCloseTags: true }); // Live preview editor.on("change", function() { clearTimeout(delay); delay = setTimeout

Why are these two javascript functions not equivalent?

馋奶兔 提交于 2019-12-08 12:37:21
问题 This function works: function refreshCodeMirror(){ $("textarea").each(function(){ var codeMirror = $(this).data('codeMirror'); setTimeout(function(codeMirror){ return function () { codeMirror.refresh(); } }(codeMirror), 10) }); } But when I tried to simplify it to this: function refreshCodeMirror(){ $("textarea").each(function(){ var codeMirror = $(this).data('codeMirror'); setTimeout(codeMirror.refresh, 10) }); } The simplification does not work. Some (possibly irrelevant) context: The

Codemirror 3 multiplexing modes using simpleHint

眉间皱痕 提交于 2019-12-08 08:48:47
问题 So I'm trying to make an SCXML editor which is basically XML (state machine) with JavaScript blocks in it. I'm close, but I'm having trouble adding hints. It seems to boil down to I don't know the editing mode I'm in when it comes time to hint. I've looked in the CodeMirror object for clues but I'm not seeing it. I'm doing the multiplexing like so: CodeMirror.defineMode("scxml", function (config) { return CodeMirror.multiplexingMode( CodeMirror.getMode(config, "text/xml"), { open: "<script>",

Codemirror gutter marker change issue

社会主义新天地 提交于 2019-12-08 07:22:52
问题 I have a requirement where i need to show line character counts in every line. I am showing it in gutter like such The limit on each line is 112, so the gutter number goes to negative when user types more than 112 characters. Everything works great. But when i do copy paste it doesn't work. The line is identified from the copy/paste texts and everything just the gutter marker which shows line character counts doesn't show. I have a little video demo of the behavior, and code posted below.

Integrating CodeMirror with Angular2 (typescript)

☆樱花仙子☆ 提交于 2019-12-08 00:39:00
问题 I'm currently working on adding a CodeMirror editor to a project, an Angular2 project more precisely. But Im' having trouble doing it. The instantiation of my editor doesn't seem to work correctly. My code is the following: editor.component.ts import {Component} from 'angular2/core' import {BrowserDomAdapter} from 'angular2/platform/browser' declare var CodeMirror: any; @Component({ selector: 'editor', templateUrl: './meang2app/partials/editor.html' }) export class Editor{ dom:

Codemirror lint feature not working react-codemirror in React/Redux/Typescript App

泪湿孤枕 提交于 2019-12-07 10:15:41
问题 I'm trying to enable the linting addon of the react-codemirror component in a React/Redux/TS app. The normal codemirror stuff works fine, syntax highlighting, line numbers, etc. However, enabling linting adds the extra padding on the left for the lint messages to the component, but no messages are displayed. I have a suspicion its something about the codemirror lint.js code not loading, but I'm not sure why. Relevant code snippets below: import * as CodeMirror from 'react-codemirror'; import

Detecting new line in codemirror

橙三吉。 提交于 2019-12-06 14:50:14
Is there any way to detect a newline in codemirror editor, either when user hits enter or a line of code wraps? p.s: in the screenshot attached 3 new lines are created by user hitting enter key (228, 229, 230), and one line (between 229 and 300) is created because of line wrapping. screenshot here: http://s9.postimage.org/gsroinedp/Screen_Shot_2012_11_19_at_11_30_09_PM.png Catching the enter key is built into the api. var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, lineWrapping:'true', extraKeys:{ Enter: function(){ alert('enter pressed'); } } }); I'm

CodeMirror Use multiple hint sources for autocomplete

家住魔仙堡 提交于 2019-12-06 14:27:31
问题 Is it possible to include multiple hint sources for autocomplete? I tried this: CodeMirror.commands.autocomplete = function(cm) { CodeMirror.showHint(cm, CodeMirror.hint.xml); CodeMirror.showHint(cm, CodeMirror.hint.html); CodeMirror.showHint(cm, CodeMirror.hint.css); CodeMirror.showHint(cm, CodeMirror.hint.javascript); }; but it seems to just include the last source file that is referenced and ignore the rest. Is there any easy way of doing this? 回答1: I found the answer to my question in