-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setCursor doesn't work well with inputStyle: "contenteditable",
#6167
Comments
Works for me in Chrome and Firefox (but since the code you show doesn't call |
In your webconsole, when you try .setCursor, the cursor will don't move |
Looking for the bugIn if (document.createRange) range = function(node, start, end, endNode) {
console.log("RANGE:")
console.log(node, start, end, endNode)
console.trace()
let r = document.createRange()
r.setEnd(endNode || node, end)
r.setStart(node, start)
return r
} Output for:
|
2nd lookingDepending of where is the cursor when I do
I try to set the focus Output for 2. focus out before setSelection()
editor.setSelection({line:0, ch:2}, {line:0, ch:5}) Output RANGE: console.trace (click to open)
editor.focus() Output RANGE: console.trace (click to open)
|
Looking how
|
3rd lookingNot usefullI saw on my last looking that Looking of setSelection declarationLooking where
Ok... I did a mistake, I forget to watch the value of Problem:
|
The condition
I think this code is not necessary, because it is already tested in L110 in |
…has focus Refine the check for whether the editor has focus to look at document.activeElement instead of state.focused. Issue #6167
Ah, right, the issue only occurs when the editor has focus within the window, but the window doesn't itself have focus. I looked at your patch but I think there's a much less invasive way to fix this. See attached patch. Does that work for you? |
My change is invasive but needed and it doesn't make depreciation and don't not changz the behavior. I need to test but in first looking (i just reviewed not test), that doesn't sound perfect with no-focus. Without calling |
I'd prefer that you actually test. It can be painful to give up one's patch, but I really much prefer the low-impact version of the fix. |
I try with: abc.html (click to open)<!doctype html>
<title>CodeMirror: Native Spellchecker Demo</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../doc/docs.css">
<link rel="stylesheet" href="../lib/codemirror.css">
<link rel="stylesheet" href="../addon/hint/show-hint.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/hint/show-hint.js"></script>
<script src="../addon/hint/anyword-hint.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Native Spellchecker Demo</a>
</ul>
</div>
<article>
<h2>Native Spellchecker Demo</h2>
<p>This editor uses <code>Codemirror.inputStyle: 'contenteditable'</code> and <code>spellcheck: true</code>.</p>
<form><textarea id="code" name="code">
Native abc tesst with contenteditableInput editor
</textarea></form>
<h2>Default Editor Mode</h2>
<p>The native spellchecker (of the browser) does not run with <code>Codemirror.inputStyle: 'textarea'</code> (default value).</p>
<form><textarea id="code2" name="code2">
No spellchecker in a textareaInput editor
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
inputStyle: 'contenteditable',
spellcheck: true
})
document.addEventListener('keydown', logKey)
function logKey(e) {
if (e.key === 'F8') {
document.body.style.background = 'red';
setTimeout(() => document.body.style.background = 'none', 500)
editor.setSelection({line:0, ch:2}, {line:0, ch:5})
} else if (e.key === 'F7') {
document.body.style.background = 'blue';
setTimeout(() => document.body.style.background = 'none', 500)
editor.focus()
} else if (e.key === 'F6') {
document.body.style.background = 'pink';
setTimeout(() => document.body.style.background = 'none', 500)
editor2.setSelection({line:0, ch:2}, {line:0, ch:5})
} else if (e.key === 'F5') {
document.body.style.background = 'cyan';
setTimeout(() => document.body.style.background = 'none', 500)
editor2.focus()
}
e.preventDefault()
return false
}
editor.focus()
var editor2 = CodeMirror.fromTextArea(document.getElementById('code2'), {})
</script>
</article> Like I say, in contenteditableInput the selection appear only when the textarea have focus but in textareaInput the selection always appear (with or without focus). I think you would the same behavior depending of the Style. |
(I got a bug with editor2.focus(), it seems to not work, I mean I can't write directly after I got the focus with this function in editor2) |
That's just how the native selection works, so it is kind of implied in the decision to use the native selection. |
Can you publish your change on npm ? |
CodeMirror uses a monthly release cycle. There'll be a new release around the 20th of the month. |
@marijnh I tried your code on master of Easymde: My change works fine, your change seem to doesn't work, I let you try: zds.html (click to open)<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Example / Preview</title>
<link rel="stylesheet" href="../dist/easymde.min.css">
<script src="../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="myText"></textarea>
<script>
var easyMDE = new EasyMDE({
element: document.getElementById('myText'),
spellChecker: false,
inputStyle: 'contenteditable',
autosave: {
enabled: true,
uniqueId: 12,
submit_delay: 10000,
delay: 1000
},
indentWithTabs: false,
minHeight: 200,
placeholder: 'Votre message au format Markdown',
promptURLs: true,
promptTexts: {
image: 'Url de votre image',
link: 'Url de votre lien'
},
uploadImage: true,
imageUploadFunction: () => {},
imageTexts: {
sbInit: 'Joindre des images par glisser-déposer ou coller depuis le presse-papiers.',
sbOnDragEnter: 'Déposer l"image pour l"envoyer dans votre galérie',
sbOnDrop: 'Téléchargement d"images #images_names#',
sbProgress: 'Téléchargement #file_name#: #progress#%',
sbOnUploaded: 'Image téléchargée #image_name#'
},
nativeSpellcheck: true,
promptAbbrv: true,
theme: 'idea',
previewRender: () => {},
syncSideBySidePreviewScroll: false
});
</script>
</body>
</html> My change (PR #6168) :Your commit/master branch :I add a color change, to show you that it is been the last version of codemirror in git (not the old one). |
On my PR, i did 4 commits : Each commit is one step, you can try each commit step by step.
|
(If my change need to be enabled with option tell me I will make this changes). |
That isn't actually unused code. The focus field in an operation will hold false or a DOM node. Your fix seems to unconditionally mess with the DOM selection, which is not a good idea (when the user doesn't have the editor focused, but for some reason its content is changed, that'll disrupt the selection). So, again, I don't want to merge these changes. Running just CodeMirror, without any external code, I can really verify that the problem is gone with my patch. If can set up a demo without your codebase that still shows the problem, let me know, but for now I'm closing this. |
@marijnh Please, I haven't finished yet, can you reopen ? I can prove it without easymde (I wanted to save some time with remaking an existing script). I will not speak again of easymde, here. Why am I sure?
My example with only codemirror: var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
inputStyle: 'contenteditable',
spellcheck: true
})
document.getElementById('icanproveit').addEventListener('click', function () {
const cm = editor;
const startPoint = cm.getCursor('start');
const endPoint = cm.getCursor('end');
cm.replaceSelection('**' + cm.getSelection() + '**');
startPoint.ch += 2;
endPoint.ch += 2;
cm.setSelection(startPoint, endPoint)
cm.focus();
}) My full page to test: abc.html (click to open)<!doctype html>
<title>CodeMirror: Native Spellchecker Demo</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../doc/docs.css">
<link rel="stylesheet" href="../lib/codemirror.css">
<link rel="stylesheet" href="../addon/hint/show-hint.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/hint/show-hint.js"></script>
<script src="../addon/hint/anyword-hint.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Native Spellchecker Demo</a>
</ul>
</div>
<article>
<h2>Native Spellchecker Demo</h2>
<p>This editor uses <code>Codemirror.inputStyle: 'contenteditable'</code> and <code>spellcheck: true</code>.</p>
<input type="button" id="icanproveit" value="ok" />
<form><textarea id="code" name="code">
Native abc tesst with contenteditableInput editor
</textarea></form>
<h2>Default Editor Mode</h2>
<p>The native spellchecker (of the browser) does not run with <code>Codemirror.inputStyle: 'textarea'</code> (default value).</p>
<input type="button" id="icanproveit2" value="ok" />
<form><textarea id="code2" name="code2">
No spellchecker in a textareaInput editor
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
inputStyle: 'contenteditable',
spellcheck: true
})
document.getElementById('icanproveit').addEventListener('click', function () {
const cm = editor;
const startPoint = cm.getCursor('start');
const endPoint = cm.getCursor('end');
cm.replaceSelection('**' + cm.getSelection() + '**');
startPoint.ch += 2;
endPoint.ch += 2;
cm.setSelection(startPoint, endPoint)
cm.focus();
})
editor.focus()
var editor2 = CodeMirror.fromTextArea(document.getElementById('code2'), {})
document.getElementById('icanproveit2').addEventListener('click', function () {
const cm = editor2;
const startPoint = cm.getCursor('start');
const endPoint = cm.getCursor('end');
cm.replaceSelection('**' + cm.getSelection() + '**');
startPoint.ch += 2;
endPoint.ch += 2;
cm.setSelection(startPoint, endPoint)
cm.focus();
})
</script>
</article> Result: |
I see—that's a different issue from the one before, though. Attached patch seems to help with that. |
This work fine thanks you! |
* Wire up shift-delete to fire a cut event on Gecko Issue codemirror#6061 * [julia mode] Fix getting stuck on integers with leading zeroes Closes codemirror#6064 * [continuecomment addon] Continue comments when a newline is inserted before them Fix issue where lastIndexOff was accidentally passed a negative start position, which causes it to search from the end of the string. Closes codemirror#6065 * Adjust posFromMouse to handle arbitrary xRel field values Closes codemirror#6067 * [vim bindings] Skip folded code when moving with j/k * [elm mode] Sync with upstream implementation Modifies this module to reflect changes made to this mode found in https://github.com/elm/elm-lang.org/blob/master/editor/cm/mode/elm.js * [cypher mode] Added keywords for system commands Includes multi database and privilege management commands * Support functions as fold widget argument So that the widgets can be dynamic with regards to their content. Expand the fold demo with a JSON editor that shows the number of elements in folded regions. * [sql mode] Support backslash and escape constants in pgsql Add support for escape constant as mentioned here: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE * [sql mode] Simplify patch 3e6aafd Issue codemirror#6081 * Add a className option to addLineWidget Issue codemirror#5952 * [javascript-hint addon] Properly iterate over local scopes See https://discuss.codemirror.net/t/function-parameter-autocomplete/2240/1 * [sublime bindings] Make by-sub-word motion more conformant to Sublime Closes codemirror#6091 * [sublime bindings] Fix sub-word motion at start of word * Mark version 5.50.0 * [sublime bindings] Add shortcut Ctrl-K Ctrl-D: find_under_expand_skip * [soy mode] Add support for default param value * Fix indentation after a {literal{/literal} block. * Fix: Broken line widget removal Removal of line widgets is broken in 5.50.0 due to invalid classname check * [nsis mode] Add commands up to NSIS v3.05 * Restore indentation when closing an array or generator. * Mark version 5.50.2 * If valid and invalid files are drag n dropped, paste all valid files * [rust mode] Fixed type names in demo code * Fix broken link in manual The external link to the ternjs.net demo page returns a 404 error; this PR corrects it. * [elm mode] Remove tab character * [show-hint addon] Scroll initially selected hint into view See https://discuss.codemirror.net/t/show-selectedhint-in-very-long-list-of-hints/2255 * [real-world uses] Add Adnuntius * Make sure clearHistory clears all linked histories Closes codemirror#6108 * [vim] fix R key in visual mode * [vim] fix behavior of ' and ` marks * [vim] implement gi gI gJ * Make sure contextmenu event is also forwarded when fired on the input field Since Firefox, as of patch a21ea6f, seems to fire it on the textarea. Closes codemirror#6116 * When direction=rtl, fix home/end and arrow motion across line boundaries Closes codemirror#6117 * Mark version 5.51.0 * Update CHANGELOG.md * Fix confused markup in releases.html * [javascript mode] Don't get confused by trailing commas in parentheses Closes codemirror#6120 * Fix bug in bidi algorithm Arabic numerals were ordered incorrectly in an rtl context. Issue codemirror#6117 * Make goLineStartSmart behave better in direction=rtl docs * [dart mode] Add "yield" keyword * [lint addon] Add theme class name to tooltips * [stylus mode] Don't match #-rgb colors before a dash character Closes codemirror#6132 * Fix missing clipPos calls in file drop code Closes codemirror#6127 * [lint addon] Allow appending the tooltip to the wrapper element The tooltip in the existing way append to the body. When applied the codemirror context inside a shadow root (custom element) this calls append the tooltip out of the root components. Thus, the user has to monkey patch the appendchild method to override the behavior. This change would allow the tooltip to render in its own context with the `selfContain` option. * Fix previous patch to get option from the parsed option object Issue codemirror#6135 * [soy mode] Remove templates property from state * Fix driver from only running vim tests. * Improve time complexity. * Clip negative scroll-to coordinates Closes codemirror#6139 * [Soy] Improve map, list, record and list comprehension highlighting * Add support for map, list and record types. * Add support for list, record and map literals. * Add support for list comprehension. * Better variable matching in list comprehension. * [tern addon] Allow appending the tooltip to the codemirror hint options container if exists The current implementation of tern.js is appending the tooltip to the body. When applied the codemirror context inside a shadow root, tooltips are falling out of the root component. This change would append the tooltip to the container of codemirror hint options if it has else it will default to document.body * Fixing blockquote end check * [sTeX mode] Ensured that tag does not clash with object prototype properties * [verilog] Support folding by indentation * Update to add mllike mode in release * Mark as version 5.49.4 * Mark version 5.52.0 * [protobuf mode] Enable brace folding * [markdown mode] DIsallow single dash for a setext header Closes codemirror#6129 * Fix lint warnings * Fix failing the test when the linter finds an issue Issue codemirror#6156 * [real world uses] Add clone-it.github.io Using CodeMirror as HTML & CSS editors. * Add plantuml language mode * Mark as version 5.49.5 * [twig mode] Replace confusing/broken code in demo * [javascript mode] Don't get confused by missing expression in statement conditions Issue codemirror#4386 * Fix DOM selection update in contenteditable mode when another window has focus Refine the check for whether the editor has focus to look at document.activeElement instead of state.focused. Issue codemirror#6167 * Make sure to set the DOM selection on ContentEditableInput.focus Issue codemirror#6167 * add missing CSS properties * [vim bindings] Disable autocorrect for prompt * [zenburn theme] Improve specificity of background selector Closes codemirror#6180 * Fix bug in viewport updating for content-sized editors Closes codemirror#6181 * Mark version 5.52.2 * [powershell mode] Don't highlight backslashes as errors * [dialog addon] Don't close dialogs when tab loses focus * [vim keymap] Fix EOL handling in visual mode. Vim's visual mode allows the cursor to be positioned over EOL. This change fixes a bug where that EOL behavior only worked when in visual block mode. * [vim keymap] Don't mark fat cursor over EOL. This fixes a bug where a mouse click to the right of a line results in the cursor apparently over EOL, even though it is actually positioned over line.length-1. Cursor position should display over EOL only in visual or insert modes. Insert mode is handled by default cursor behavior and visual mode is handled by the fake cursor, so we should remove the special cursor EOL handling here and just clip to show the cursor in the right place. * [runmode-stanadlone addon] Update with changes from runmode.js This PR updates the `runMode` function in runmode-standalone.js with 3 commits from [runmode.js](https://github.com/codemirror/CodeMirror/blob/master/addon/runmode/runmode.js): - codemirror@7e35f03 - codemirror@53bc4b1 - codemirror@64113ec The first commit from runmode.js allows the `callback` in runMode to be a function, as mentioned in https://codemirror.net/demo/runmode.html and https://discuss.codemirror.net/t/runmode-standalone-callback/2357. The last two commits fixes a copy-and-paste bug from IE. * Add a screenReaderLabel option to set an aria-label on the editor * Remove leftover argument Issue codemirror#6197 * [merge addon] Compensate for editor top offset when aligning lines Closes codemirror#6202 * [hint] Nicer scrolling with non-standard padding The `scrollToActive` function used to have a `3px` offset hardcoded, which matches the default style (`padding: 2px; border-width: 1px;`). Custom values for these these style attributes would lead to a small visual bug. * [show-hint addon] don't close hints on backspace prematurely Currently, when a completion is triggered with part of the identifier already typed and backspace is hit, hints are immediately closed (when cursor is moved before the original position that completion was triggered for). After this change, they will be closed only when the entire identifier is erased (cursor is moved before the identifier start). * Add functions to vimAPI documentation * [julia mode] Fix infinite loop for mismatched brackets Closes codemirror#6213 * docs: Fix simple typo, compatiblity -> compatibility There is a small typo in addon/search/searchcursor.js, mode/python/python.js. Should read `compatibility` rather than `compatiblity`. * [show-hint] Scroll cursor into view after picking **Fixes a minor visual bug:** The picked hint might push the cursor out of the screen - this scrolls the cursor back into view. (Would normally happen after the next keypress.) * [JavaScript-Hint] Add options.additionalContext property names as hints ... if not hinting within 'context' * [sublime keymap] Add Ctrl-K Ctrl+1 fold all shortcut * Make refresh always re-estimate line heights when wrapping is on Closes codemirror#6228 * [emacs keymap] Allow fallthrough to the default keymap Closes codemirror#6231 * [rust] Add some keywords * doc update to clarify that negative lookbehind assertion for regex is not supported * [show-hint] Make linter happy * [wast] Add new wast mode (for WebAssembly disassembly) This adds support for WebAssembly text format, as used in the browser DevTools (Firefox, Edge and Chrome DevTools all the like). * Mark version 5.53.0 * [show-hint addon] Fix broken completion picking Closes codemirror#6239 * Mark version 5.53.2 * Don't handle key events for the wrong target Closes codemirror#6242 * Add SASS2CSS https://www.sass2css.online/ * [python mode] Somewhat improve handling of format specs in format strings Issue codemirror#6244 * Disable scroll-on-focus in drag focus kludge Since it causes jumps in the scroll position on Chrome. Closes codemirror#6246 * [vim bindings] Remove a duplicate entry in defaultExCommandMap * Disable scroll workaround in start-drag handler for Safari Issue codemirror#6246 * [javascript mode] Add support for private properties Issue codemirror#6249 * [javascript mode] Allow class fields in non-TS mode Closes codemirror#6249 * Don't mess with the selection when refocusing a text field Issue codemirror#6242 * [runmode standalone] Add support for globalThis We use the standalone mode in DevTools in a worker, where `window` does not exist. Instead, we can use `globalThis` which should be the corresponding global scope in all scenarios. For older browsers that do not support `globalThis`, we fallback to `window`. Relevant DevTools change: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2174418/1/front_end/third_party/codemirror/package/addon/runmode/runmode-standalone.js * Also ignore clipboard events inside widgets in contenteditable input mode Issue codemirror#6242 * [matchbrackets addon] Disable highlighting when the editor isn't focused Closes codemirror#6252 * [javascript operator] Properly implement optional chaining operator Closes codemirror#6255 * Increase size of scrollbar-hack gap Issue codemirror#6258 * Add a sponsors section to the website * [tcl mode] Add # as a lineComment * [dart mode] Add `late` and `required` keywords, `Null` and `Never` types * [mode/meta] Remove unwanted space in TiddlyWiki mode name * [runmode addon] Add support for lookahead Closes codemirror/google-modes#300 * [javascript mode] Fix a runaway regexp Issue codemirror#6273 * Proper escaping of \s See: https://lgtm.com/rules/1510624619946/ * [match-highlighter] Fix issue in highlighting non-alphanumeric tokens Closes codemirror#6279 * [vim] Allow Ex-Commands with non-word names * [soy mode] Fix bug with "map" in type name Co-authored-by: Axel Lewenhaupt <lewenhaupt@lewenhaupt-macbookpro2.roam.corp.google.com> * [gfm mode] add fencedCodeBlockDefaultMode option * Mark version 5.54.0 * Don't render zero-width joiners as a special character Since it'll often mess up emoji rendering Issue codemirror#4488 * [real-world uses] Add Adaface PairPro Adding Adaface PairPro (remote pair programming tool with code editor, compiler and video conference) for interviews. Added in alphabetical order. * [vim] Fix vim-mode-change event being signalled twice * [gfm mode] Allow forward slash in fenced code language * [loadmode addon] Support overriding script loading and filename computation Issue codemirror#6295 Issue codemirror#6294 * Remove trailing whitespace * [runmode-standalone addon] Fix interface mismatch in StringStream constructor Closes codemirror/google-modes#300 * [javascript mode] Only allow HTML-style comments at the start of line Closes codemirror#6305 * [javascript mode] Reduce start-of-line restriction to HTML close comment tokens Issue codemirror#6305 * [pascal mode] Add highlighting for comments with curly brackets See codemirror#5523 * [markdown mode] Change fencedCodeBlockDefaultMode to 'text/plain' instead of '' * [julia mode] Tweak indent method * Fix lint error * [wast mode] update to match latest WebAssembly specification Also shorten the regex for the keyword tokens a bit. * [wast mode] Support atomics from the Wasm Threads proposal This also adds more test coverage for not only the atomic memory instructions, but also the regular memory instructions. It also shortens the regex's for keyword and atom a bit. * [sql-hint addon] Autocomplete suggestion on _ $ and # for ODBC * [wast mode] Support WebAssembly tail-calls proposal This also adds more test coverage for all other control instructions, not just the new ones from the tail-calls proposal. * [real-world uses] Add Innovay Web Tools * [runmode addon] Reuse existing support code for standalone/node versions of runmode * [runmode.node addon] Export countColumn again * [runmode addon] Fix lint issues * [closetag addon] Make whenClosing/whenOpening properly default to true Closes codemirror#6322 * Mark version 5.55.0 * [wast mode] Rename atomic.notify and *.atomic.wait Refs: WebAssembly/threads#149 * [wast mode] Support some Wasm SIMD instructions These keywords can be found at https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md. * [wast mode] Add more SIMD instructions This adds all comparison (eq, ne, lt, gt, le, ge), and v8x16.shuffle and v8x16.swizzle. Full list of instructions found at: https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md The ordering in the test file follows this the ordering in the binary form. The regex ordering is more arbitrary due to grouping. * [wast mode] Add more SIMD instructions Some arithmetic instructions, had to shuffle the regex a bit so that we will attempt to match i8x16.add_saturate_s first before i8x16.add. Full list available at: https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md * [wast mode] More SIMD instructions f32x4 and f64x2 arithmetic instructions. Sorted test cases to match the order in https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md to make it easier to spot missing instructions. * [wast mode] Complete SIMD instructions This finished the set of SIMD instructions 178 of them in total, also sorted tests by their ordering in https://github.com/WebAssembly/simd/blob/master/proposals/simd/BinarySIMD.md. * [sas mode] Add missing keywords I've noticed these few are missing. All from PROC MIXED * [vim bindings] Document events fired by vim mode * Fix line-wise pasting on Chrome Windows Closes codemirror#6337 * [hardwrap addon] introduce forceBreak * [hardbreak addon] Adjust formatting Issue codemirror#6338 * Add support for import expressions. Committer: Axel Lewenhaupt <axel@x2d.org> * [soy mode] Support template type Co-authored-by: Axel Lewenhaupt <lewenhaupt@google.com> * [soy mode] Add support for index in for loops - Fix variable scrope issue with list comprehensions. Co-authored-by: Axel Lewenhaupt <lewenhaupt@google.com> * [sql-hint addon] Treat single quotes like double quotes when looking at tokens See https://discuss.codemirror.net/t/codemirror-ignore-show-hints-if-the-class-is-cm-string/2513 * Stop linking to the github wiki * [show-hint addon] Introduced option 'scrollMargin' * Mark version 5.56.0 * [vim bindings] Support tag text objects in xml / htmlmixed mode User can use `t` to operate on tag text objects. For example, given the following html: ``` <div> <span>hello world!</span> </div> ``` If the user's cursor (denoted by █) is inside "hello world!": ``` <div> <span>hello█world!</span> </div> ``` And they enter `dit` (delete inner tag), then the text inside the enclosing tag is deleted -- the following is the expected result: ``` <div> <span></span> </div> ``` If they enter `dat` (delete around tag), then the surrounding tags are deleted as well: ``` <div> </div> ``` This logic depends on the following: - mode/xml/xml.js - addon/fold/xml-fold.js - editor is in htmlmixedmode / xml mode Caveats This is _NOT_ a 100% accurate implementation of vim tag text objects. For example, the following cases noop / are inconsistent with vim behavior: - Does not work inside comments: ``` <!-- <div>broken</div> --> ``` - Does not work when tags have different cases: ``` <div>broken</DIV> ``` - Does not work when inside a broken tag: ``` <div><brok><en></div> ``` This addresses codemirror#3828. * Fix plantuml mode title * Add csv simple mode * Update links and meta * Fix MIME type * [real-world uses] Add CodeMirror-Record (codemirror#6360) * [real-world uses] Add Violentmonkey * [css] add missing 1) property all, 2) media feature prefers-color-scheme * [mode meta] Escape dot in mode's filename regex * [comment addon] Keep selection in front of closing marker when block-commenting ... with fullLines==false when the end of the selection is directly on the closing marker. Closes codemirror#6375 * [julia mode] Make sure dedent tokens end in a word boundary Closes codemirror#6376 * [css mode] Add missing standard property names per MDN * [css] missing CSS property values - for mask-image, mask-origin, touch-action just added * Mark as version 5.49.6 * Document the scrollpastend addon Closes codemirror#6381 * Add issue and pr templates that warn about common problems * Add graphviz simple mode * Mark as version 5.49.7 * Fix modeInfo might not be initialized first * Mark as version 5.49.8 * chore: update package namespace * [nsis mode] Add NSIS 3.06 commands * Annotate scrollbar when matches are folded * [annotatescrollbar addon] Simplify visual-line finding Issue codemirror#6388 * [xml-hint addon] Allow attribute values function to return a Promise * Check state.pending length * Fix csv regex undefined matching group Ref: codemirror#5374 (comment) * Fix state.pending might be empty array * Improve csv token colorization * Add warnings for now * Mark as version 5.49.9 * Recognise Cmd key in Firefox * Fix keyName function for Cmd key Corrects return value, expected "Mod" instead of "Cmd-Mod". * Mark version 5.57.0 * [real-world uses] Add Intervue * Upgrade markdown_math.js for 5.57.0 * Mark version 5.57.1 * chore: run build and release before publish instead of install * chore: run build and release before publish instead of install * Mark as version 5.57.2 * [ruby mode] Add keyword lists as a hintWords helper * [javascript mode] Improve handling of &&, ||, and ?? operators Closes codemirror#6394 * Don't default vim demo to contenteditable That option was apparently left over from a debugging session * [vim] Add black hole register * Add desmos sponsor link * Make backspace delete by codepoint Closes codemirror#6408 * Fix bug causing a deleted editor to continue believing it had focus Which kept the cursor blink and input poll intervals alive, leaking memory. Closes codemirror#6410 * Suppress focus outline for scrollbar elements Issue codemirror#6412 * Add vim emulation support for `gn` and `gN`. If we are given the following snippet of text: ``` A green green sky. _ ``` We can search for the word "green" with `/green`, and then use `gn` to select the next occurrence of "green" in visual mode. ``` A green green sky. ----- ``` Alternatively, we can use `cgn` and then enter the word "blue" to change the word "green" to "blue". ``` A blue green sky. ``` Then we can use the `.` operator to repeat the change: ``` A blue blue sky. ``` Addresses codemirror#3851. * Fix drawing of marked text with only attributes Closes codemirror#6414 * [lint addon] Use separate CSS classes for common lint styles This changes lint.css to be less reliant on the predefined severities (error and warning), in turn making it easier to define custom ones. Now all that needs to be done in order to define a new severity, e.g. `note`, is to add the following CSS: ```css /* underline */ .CodeMirror-lint-mark-note { background-image: ...; } /* icon */ .CodeMirror-lint-marker-note, .CodeMirror-lint-message-note { background-image: ...; } ``` Previously, it was necessary to copy many styles that were only available under the `CodeMirror-lint-*-error` and `CodeMirror-lint-*-warning` classes. * [lint addon] Put error CSS after warning By swapping the CSS rules, the error rules take priority in case there are markers with both severities on the same token. That token is now underlined red instead of yellow, making it consistent with how errors take priority in the gutter. * Set the readonly attribute on the hidden textarea when the editor is read-only This prevents cut/paste from showing up in the context menu on Chrome (but doesn't help on Firefox). Closes codemirror#6418 * Update placeholder visibility during composition Closes codemirror#6420: * Mark version 5.58.0 * Fix use of ES6 in addon * [placeholder addon] Fix composition handling Issue codemirror#6422 * Mark version 5.58.1 * [julia mode] Fix infinite recursion I couldn't figure out what the original code was intended to do, but I've tried to fix the problem without changing it more than necessary. Closes codemirror#6428 * Fixes codemirror#6331. Backticks are stripped from SQL query words before comparison * [tern demo] Use unpkg, now that the URL structure of ternjs.net changed * Remove link to gitter room It never took off, and I very much prefer communicating through the forum and bug tracker. * Fixes codemirror#6402. Adds option to turn off highlighting of non-standard CSS properties * Fix doc/releases.html copy-paste mistake * Support disableAutoIncrementMarkdownListNumbers option * Disable incrementRemainingMarkdownListNumbers * Fix bullet not assigned * Mark as version 5.57.3 * Fix horizontal scrolling-into-view with non-fixed gutters Closes codemirror#6436 * [javascript mode] Fix potentially-exponential regexp * [sparql mode] Improve parsing of IRI atoms * Do not treat the opening '<' of an expanded IRI atom as an operator The existing code would not highlight the IRI atom "<foo#bar>" in the following line as an atom. FILTER( ?x = "42"^^<foo#bar> ) for example everything after the # would be highlighted as a comment. This is because the sequence "^^<" while all "operator characters", are not all SPARQL operators in this case: the "<" introduces the IRI atom. I special-case the "^^". * Improve PN_LOCAL parsing to SPARQL 1.1 The following legal sequences of characters from SPARQL 1.1 are additionally parsed as being the right-hand-side of a prefixed IRI. 1) Colons 2) PERCENT escaping 3) PN_LOCAL_ESCAPE escaping * [javascript mode] Don't indent in template strings Closes codemirror#6442 * [stylus mode] Recognize "url-prefix" token properly * Add WebAssembly to meta * Mark version 5.58.2 Co-authored-by: Marijn Haverbeke <marijn@haverbeke.nl> Co-authored-by: leaf <node_github@163.com> Co-authored-by: T. Brandon Ashley <tbash@users.noreply.github.com> Co-authored-by: Olivia Ytterbrink <olivia@ytterbrink.com> Co-authored-by: Opender Singh <opender94@gmail.com> Co-authored-by: Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> Co-authored-by: Axel Lewenhaupt <axel@x2d.org> Co-authored-by: Axel Lewenhaupt <lewenhaupt@lewenhaupt-macbookpro2.roam.corp.google.com> Co-authored-by: Hanno Fellmann <fellmann@users.noreply.github.com> Co-authored-by: Jan T. Sott <jan@idleberg.com> Co-authored-by: elpnt <39664774+elpnt@users.noreply.github.com> Co-authored-by: James Cockshull <james.cockshull@gmail.com> Co-authored-by: antosarho <tsarhanis@gmail.com> Co-authored-by: nightwing <amirjanyan@gmail.com> Co-authored-by: David Rodrigues <david.proweb@gmail.com> Co-authored-by: kvncp <kevincpeterson@gmail.com> Co-authored-by: Roman Janusz <romeqjanoosh@gmail.com> Co-authored-by: Teja <tejasrivastav@gmail.com> Co-authored-by: vamshi.revu <vamshi.revu@servicenow.com> Co-authored-by: Jay Contonio <jay@conton.io> Co-authored-by: rvalavicius <rytis.valavicius@gmail.com> Co-authored-by: mtaran-google <mtaran@google.com> Co-authored-by: Max Wu <jackymaxj@gmail.com> Co-authored-by: Hein Htat <heinthuhtat@gmail.com> Co-authored-by: Ilya Zverev <ilya@zverev.info> Co-authored-by: Ilya Zverev <zverik@textual.ru> Co-authored-by: clone-it <61330489+clone-it@users.noreply.github.com> Co-authored-by: Yukai Huang <yukaihuangtw@gmail.com> Co-authored-by: Patrick Kettner <patrickkettner@gmail.com> Co-authored-by: Erik Welander <ewelander@google.com> Co-authored-by: Matthew Casperson <matthewcasperson@gmail.com> Co-authored-by: benhormann <benhormann@users.noreply.github.com> Co-authored-by: Alex Churchill <al.churchill@gmail.com> Co-authored-by: BrianHung <brianhung@berkeley.edu> Co-authored-by: Aditya Toshniwal <aditya.toshniwal14@gmail.com> Co-authored-by: Fons van der Plas <fonsvdplas@gmail.com> Co-authored-by: ianhi <ianhuntisaak@gmail.com> Co-authored-by: Tim Gates <tim.gates@iress.com> Co-authored-by: cBiscuit87 <36653704+cBiscuit87@users.noreply.github.com> Co-authored-by: Mélanie Chauvel <perso@hack-libre.org> Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com> Co-authored-by: d8888 <smallt@gmail.com> Co-authored-by: Benedikt Meurer <bmeurer@google.com> Co-authored-by: Dinindu D. Wanniarachchi <12568779+DininduWanniarachchi@users.noreply.github.com> Co-authored-by: John Chen <johnchen902@gmail.com> Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com> Co-authored-by: Peter László <ptrlaszlo@gmail.com> Co-authored-by: Sam Rawlins <srawlins@google.com> Co-authored-by: Boris K <kubiakboris@gmail.com> Co-authored-by: Ajin Abraham <ajin25@gmail.com> Co-authored-by: Jack Douglas <jack@douglastechnology.co.uk> Co-authored-by: Siddhartha Gunti <siddhartha.gunti191@gmail.com> Co-authored-by: ZeeshanNoor <zyshan.noor@gmail.com> Co-authored-by: Ealton <longjdai@gmail.com> Co-authored-by: Ng Zhi An <zhin@google.com> Co-authored-by: Paul Schmidt <schmidtpaul@hotmail.de> Co-authored-by: Kaushik Kulkarni <kaushikcfd@gmail.com> Co-authored-by: Axel Lewenhaupt <lewenhaupt@google.com> Co-authored-by: Bin Ni <nibin@quantil.com> Co-authored-by: Howard <howard.jing@gmail.com> Co-authored-by: Haoran Yu <haoran_yu@hotmail.com> Co-authored-by: orionlee <orionlee@yahoo.com> Co-authored-by: Lucas Buchala <lucasbuchala@gmail.com> Co-authored-by: tokafew420 <tokafew420@gmail.com> Co-authored-by: Leo Baschy <srguiwiz12@nrvnr.com> Co-authored-by: Intervue <62877278+Intervue@users.noreply.github.com> Co-authored-by: Howard Jing <howardjing@google.com> Co-authored-by: Adrian Kunz <clashsoft@hotmail.com> Co-authored-by: Nina Pypchenko <22447785+nina-py@users.noreply.github.com> Co-authored-by: Mark Boyes <mark.boyes@oxfordsemantic.tech> Co-authored-by: tophf <tophf@gmx.com> Co-authored-by: David R. Myers <davidrmyersii@gmail.com>
Hi,
When I try to do
editor.setCursor({line: 0, ch: 2})
withinputStyle: "contenteditable",
setting, the cursor doesn't change this position but this work fine withinputStyle: "editor",
.I'm looking to make a fix/pr, if you have advice about fixing this issue, please feel free to comment.
Example with demo/abc.html :
(External linked issue : Ionaru/easy-markdown-editor#160 & zestedesavoir/zds-site#5652)
The text was updated successfully, but these errors were encountered: