Active Line Demo
Styling the current cursor line.
pax_global_header 0000666 0000000 0000000 00000000064 13611327467 0014524 g ustar 00root root 0000000 0000000 52 comment=19b75cbf7d7f4aa2965de3f0de05a11ff24f6ffb CodeMirror-5.51.0/ 0000775 0000000 0000000 00000000000 13611327467 0013661 5 ustar 00root root 0000000 0000000 CodeMirror-5.51.0/.editorconfig 0000664 0000000 0000000 00000000127 13611327467 0016336 0 ustar 00root root 0000000 0000000 root = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 CodeMirror-5.51.0/.gitattributes 0000664 0000000 0000000 00000000240 13611327467 0016550 0 ustar 00root root 0000000 0000000 *.txt text eol=lf *.js text eol=lf *.html text eol=lf *.md text eol=lf *.json text eol=lf *.yml text eol=lf *.css text eol=lf *.svg text eol=lf CodeMirror-5.51.0/.gitignore 0000664 0000000 0000000 00000000154 13611327467 0015651 0 ustar 00root root 0000000 0000000 /node_modules /npm-debug.log /package-lock.json /test*.html .tern-* *~ *.swp .idea *.iml /lib/codemirror.js CodeMirror-5.51.0/.npmignore 0000664 0000000 0000000 00000000251 13611327467 0015656 0 ustar 00root root 0000000 0000000 /node_modules /demo /doc /test /test*.html /index.html /mode/*/*test.js /mode/*/*.html /mode/index.html .* /bin/authors.sh /bin/lint /bin/release /bin/upload-release.js CodeMirror-5.51.0/.travis.yml 0000664 0000000 0000000 00000000075 13611327467 0015774 0 ustar 00root root 0000000 0000000 language: node_js node_js: - stable sudo: false cache: npm CodeMirror-5.51.0/AUTHORS 0000664 0000000 0000000 00000025503 13611327467 0014736 0 ustar 00root root 0000000 0000000 List of CodeMirror contributors. Updated before every release. 4oo4 4r2r Aaron Brooks Abdelouahab Abdussalam Abdurrahman Abe Fettig Abhishek Gahlot Adam Ahmed Adam King Adam Particka adanlobato Adán Lobato Aditya Toshniwal Adrian Aichner Adrian Heine Adrien Bertrand aeroson Ahmad Amireh Ahmad M. Zawawi ahoward Akeksandr Motsjonov Alasdair Smith AlbertHilb Alberto González Palomo Alberto Pose Albert Xing Alexander Pavlov Alexander Schepanovski Alexander Shvets Alexander Solovyov Alexandre Bique alexey-k Alex Piggott Aliaksei Chapyzhenka Allen Sarkisyan Ami Fischman Amin Shali Amin Ullah Khan amshali@google.com Amsul amuntean Amy Ananya Sen anaran AndersMad Anders Nawroth Anderson Mesquita Anders Wåglund Andrea G Andreas Reischuck Andres Taylor Andre von Houck Andrew Cheng Andrew Dassonville Andrey Fedorov Andrey Klyuchnikov Andrey Lushnikov Andrey Shchekin Andy Joslin Andy Kimball Andy Li Angelo angelozerr angelo.zerr@gmail.com Ankit Ankit Ahuja Ansel Santosa Anthony Dugois anthonygego Anthony Gégo Anthony Grimes Anton Kovalyov antosarho Apollo Zhu AQNOUCH Mohammed Aram Shatakhtsyan areos Arnab Bose Arnoud Buzing Arsène von Wyss Arthur Müller Arun Narasani as3boyan asolove atelierbram AtomicPages LLC Atul Bhouraskar Aurelian Oancea Axel Lewenhaupt Baptiste Augrain Barret Rennie Bartosz Dziewoński Basarat Ali Syed Bastian Müller belhaj Bem Jones-Bey benbro Beni Cherniavsky-Paskin Benjamin DeCoste Benjamin Young Ben Keen Ben Miller Ben Mosher Bernhard Sirlinger Bert Chang Bharad BigBlueHat Billy Moon binny Bjorn Hansen B Krishna Chaitanya Blaine G blukat29 Bo boomyjee Bo Peng borawjm Brad Metcalf Brandon Frohs Brandon Wamboldt Bret Little Brett Zamir Brian Grinstead Brian Sletten brrd Bruce Mitchener Bruno Logerfo Bryan Gin-ge Chen Bryan Massoth Caitlin Potter Calin Barbat callodacity Camilo Roca Casey Klebba César González Íñiguez Chad Jolly Chandra Sekhar Pydi Charles Skelton Cheah Chu Yeow Chhekur Chris Colborne Chris Coyier Chris Ford Chris Granger Chris Houseknecht Chris Lohfink Chris Morgan Chris Reeves Chris Smith Christian Gruen Christian Oyarzun Christian Petrov christopherblaser Christopher Brown Christopher Kramer Christopher Mitchell Christopher Pfohl Christopher Wallis Chunliang Lyu ciaranj clso CodeAnimal CodeBitt coderaiser Cole R Lawrence ComFreek Cristian Prieto Curran Kelleher Curtis Gagliardi dagsta daines Dale Jung Dan Bentley Dan Heberden Daniel, Dao Quang Minh Daniele Di Sarli Daniel Faust Daniel Hanggi Daniel Huigens Daniel Kesler Daniel KJ Daniel Neel Daniel Parnell Daniel Thwaites Danila Malyutin Danny Yoo darealshinji Darius Roberts databricks-david-lewis Dave Brondsema Dave MacLachlan Dave Myers David Barnett David H. Bronke David Mignot David Pathakjee David Santana David Vázquez David Whittington deebugger Deep Thought Denis Ovsienko Devin Abbott Devon Carew Dick Choi Diego Fernandez dignifiedquire Dimage Sapelkin dmaclach Dmitry Kiselyov domagoj412 Dominator008 Domizio Demichelis Doug Blank Doug Wikle Drew Bratcher Drew Hintz Drew Khoury Drini Cami Dror BG Duncan Lilley duralog dwelle eborden edoroshenko edsharp ekhaled Elisée elpnt Emmanuel Schanzer Enam Mijbah Noor Eric Allam Eric Bogard Erik Demaine Erik Welander eustas Evan Minsk Fabien Dubosson Fabien O'Carroll Fabio Zendhi Nagao Faiza Alsaied Fauntleroy fbuchinger feizhang365 Felipe Lalanne Felix Raab ficristo Filip Noetzel Filip Stollár Filype Pereira finalfantasia flack Florian Felten Forbes Lindesay ForbesLindesay Ford_Lawnmower Forrest Oliphant Franco Catena Frank Seifferth Frank Wiegand fraxx001 Fredrik Borg FUJI Goro (gfx) Gabriel Gheorghian Gabriel Horner Gabriel Nahmias galambalazs Gary Sheng Gautam Mehta Gavin Douglas gekkoe Geordie Hall George Stephanis geowarin Gerard Braad Gergely Hegykozi Germain Chazot Giovanni Calò Glebov Boris Glenn Jorde Glenn Ruehle goldsmcb Golevka Google LLC Gordon Smith Grant Skinner greengiant Gregory Koberger Grzegorz Mazur Guang Li Guan Gui Guillaume Massé Guillaume Massé guraga Gustavo Rodrigues Hakan Tunc Hanno Fellmann Hans Engel Hanzhao Deng Harald Schilly Hardest Harshvardhan Gupta Hasan Delibaş Hasan Karahan Heanes Hector Oswaldo Caballero Hélio Hendrik Wallbaum Henrik Haugbølle Herculano Campos hidaiy Hiroyuki Makino hitsthings Hocdoc Hugues Malphettes Ian Beck Ian Davies Ian Dickinson Ian Rose Ian Wehrman Ian Wetherbee Ice White ICHIKAWA, Yuji idleberg Igor Petruk ilvalle Ilya Kharlamov Ingo Richter Irakli Gozalishvili Ivan Kurnosov Ivoah Jacob Lee Jaimin Jake Peyser Jakob Miland Jakub Vrana Jakub Vrána James Campos James Cockshull James Howard James Thorne Jamie Hill Jamie Morris Janice Leung Jan Jongboom jankeromnes Jan Keromnes Jan Odvarko Jan Schär Jan T. Sott Jared Dean Jared Forsyth Jared Jacobs Jason Jason Barnabe Jason Grout Jason Heeris Jason Johnston Jason San Jose Jason Siefken Jayaprabhakar Jaydeep Solanki Jean Boussier Jeff Blaisdell Jeff Hanke Jeff Jenkins jeffkenton Jeff Pickhardt jem (graphite) Jeremy Parmenter Jim Jim Avery jkaplon JobJob jochenberger Jochen Berger Joel Einbinder joelpinheiro joewalsh Johan Ask Johannes John Connor John-David Dalton John Engler John Lees-Miller John Ryan John Snelson John Van Der Loo Jon Ander Peñalba Jonas Döbertin Jonas Helfer Jonathan Dierksen Jonathan Hart Jonathan Malmaud Jon Gacnik jongalloway Jon Malmaud Jon Sangster Joo Joost-Wim Boekesteijn Joseph Pecoraro Josh Barnes Josh Cohen Josh Soref Joshua Newman Josh Watzman jots Joy Zhong jsoojeon ju1ius Juan Benavides Romero Jucovschi Constantin Juho Vuori Julien CROUZET Julien Rebetez Justin Andresen Justin Hileman jwallers@gmail.com kaniga karevn Karol Kayur Patel Kazuhito Hokamura kcwiakala Kees de Kooter Kenan Christian Dimas Ken Newman ken restivo Ken Rockot Kevin Earls Kevin Kwok Kevin Muret Kevin Sawicki Kevin Ushey Kier Darby Klaus Silveira Koh Zi Han, Cliff komakino Konstantin Lopuhin koops Kris Ciccarello ks-ifware kubelsmieci KwanEsq Kyle Kelley KyleMcNutt LaKing Lanfei Lanny laobubu Laszlo Vidacs leaf leaf corcoran Lemmon Leo Baschy Leonid Khachaturov Leon Sorokin Leonya Khachaturov Liam Newman Libo Cannici Lior Goldberg Lior Shub LloydMilligan LM lochel Lonnie Abelbeck Lorenzo Simionato Lorenzo Stoakes Louis Mauchet Luca Fabbri Luciano Longo Luciano Santana Lu Fangjian Luke Browning Luke Granger-Brown Luke Stagner lynschinzer M1cha Madhura Jayaratne Maksim Lin Maksym Taran Malay Majithia Manideep Manuel Rego Casasnovas Marat Dreizin Marcel Gerber Marcelo Camargo Marco Aurélio Marco Munizaga Marcus Bointon Marek Rudnicki Marijn Haverbeke Mário Gonçalves Mario Pietsch Mark Anderson Mark Dalgleish Mark Hamstra Mark Lentczner Marko Bonaci Mark Peace Markus Bordihn Markus Olsson Martin Balek Martín Gaitán Martin Hasoň Martin Hunt Martin Laine Martin Zagora Mason Malone Mateusz Paprocki Mathias Bynens mats cronqvist Matt Gaide Matthew Bauer Matthew Beale matthewhayes Matthew Rathbone Matthew Suozzo Matthias Bussonnier Matthias BUSSONNIER Mattia Astorino Matt MacPherson Matt McDonald Matt Pass Matt Sacks mauricio Maximilian Hils Maxim Kraev Max Kirsch Max Schaefer Max Wu Max Xiantu mbarkhau McBrainy mce2 melpon meshuamam Metatheos Micah Dubinko Michael Michael Goderbauer Michael Grey Michael Kaminsky Michael Lehenbauer Michael Wadman Michael Walker Michael Zhou Michal Čihař Michal Dorner Michal Kapiczynski Mighty Guava Miguel Castillo mihailik Mika Andrianarijaona Mike Mike Bostock Mike Brevoort Mike Diaz Mike Ivanov Mike Kadin Mike Kobit Milan Szekely MinRK Miraculix87 misfo mkaminsky11 mloginov Moritz Schubotz (physikerwelt) Moritz Schwörer Moshe Wajnberg mps ms mtaran-google Mu-An ✌️ Chiou Mu-An Chiou mzabuawala Narciso Jaramillo Nathan Williams ndr Neil Anderson neon-dev nerbert NetworkNode nextrevision ngn nguillaumin Ng Zhi An Nicholas Bollweg Nicholas Bollweg (Nick) NickKolok Nick Kreeger Nick Small Nicolas Chevobbe Nicolas Kick Nicolò Ribaudo Niels van Groningen nightwing Nikita Beloglazov Nikita Vasilyev Nikolaj Kappler Nikolay Kostov nilp0inter Nils Knappmeier Nisarg Jhaveri nlwillia noragrossman Norman Rzepka Nouzbe Oleksandr Yakovenko Olivia Ytterbrink Opender Singh opl- Oreoluwa Onatemowo oscar.lofwenhamn Oskar Segersvärd ossdev overdodactyl pablo pabloferz Pablo Zubieta paddya Page paladox Panupong Pasupat paris Paris Paris Kasidiaris Patil Arpith Patrick Stoica Patrick Strawderman Paul Garvin Paul Ivanov Paul Masson Pavel Pavel Feldman Pavel Petržela Pavel Strashkin Paweł Bartkiewicz peteguhl peter Peter Flynn peterkroon Peter Kroon Philipp A Philipp Markovics Philip Stadermann Pi Delport Pierre Gerold Pieter Ouwerkerk Pontus Melke prasanthj Prasanth J Prayag Verma prendota Prendota Qiang Li Radek Piórkowski Rahul Rahul Anand ramwin1 Randall Mason Randy Burden Randy Edmunds Randy Luecke Raphael Amorim Rasmus Erik Voel Jensen Rasmus Schultz raymondf Raymond Hill ray ratchup Ray Ratchup Remi Nyborg Renaud Durlin Reynold Xin Richard Denton Richard van der Meer Richard Z.H. Wang Rishi Goomar Robert Brignull Robert Crossfield Robert Martin Roberto Abdelkader Martínez Pérez robertop23 Robert Plummer Rrandom Rrrandom Ruslan Osmanov Ryan Pangrle Ryan Petrello Ryan Prior ryu-sato sabaca Sam Lee Sam Rawlins Samuel Ainsworth Sam Wilson sandeepshetty Sander AKA Redsandro Sander Verweij santec Sarah McAlear and Wenlin Zhang Sascha Peilicke Sasha Varlamov satamas satchmorun sathyamoorthi Saul Costa S. Chris Colbert SCLINIC\jdecker Scott Aikin Scott Feeney Scott Goodhew Seb35 Sebastian Wilzbach Sebastian Zaha Seren D Sergey Goder Sergey Tselovalnikov Se-Won Kim Shane Liesegang shaund shaun gilchrist Shawn A Shea Bunge sheopory Shil S Shiv Deepak Shmuel Englard Shubham Jain Siamak Mokhtari silverwind Simon Edwards sinkuu snasa soliton4 sonson Sorab Bisht spastorelli srajanpaliwal Stanislav Oaserele stan-z Stas Kobzar Stefan Borsje Steffen Beyer Steffen Bruchmann Steffen Kowalski Stephane Moore Stephen Lavelle Steve Champagne Steve Hoover Steve O'Hara stockiNail stoskov Stryder Crown Stu Kennedy Sungho Kim sverweij Taha Jahangir takamori Tako Schotanus Takuji Shimokawa Takuya Matsuyama Tarmil T. Brandon Ashley TDaglis tel Tentone tfjgeorge Thaddee Tyl thanasis TheHowl themrmax think Thomas Brouard Thomas Dvornik Thomas Kluyver thomasmaclean Thomas Schmid Tim Alby Tim Baumann Timothy Farrell Timothy Gu Timothy Hatcher Tobias Bertelsen TobiasBg Todd Berman Todd Kennedy Tomas-A Tomas Varaneckas Tom Erik Støwer Tom Klancer Tom MacWright Tom McLaughlin Tony Jian tophf Torgeir Thoresen totalamd Travis Heppe Triangle717 Tristan Tarrant TSUYUSATO Kitsune Tugrul Elmas twifkak Tyler Long Tyler Makaro Vadim Dyachenko Vadzim Ramanenka Vaibhav Sagar VapidWorx Vestimir Markov vf Victor Bocharsky Vincent Woo Volker Mische vtripolitakis wdouglashall Weiyan Shao wenli Wes Cossick Wesley Wiser Weston Ruter Will Binns-Smith Will Dean William Desportes William Jamieson William Stein Willy Wojtek Ptak wonderboyjon Wu Cheng-Han Xavier Mendez Yang Guo Yassin N. Hassan YNH Webdev yoongu Yunchi Luo Yuvi Panda Yvonnick Esnault Zac Anger Zachary Dremann Zeno Rocha Zhang Hao Ziv zoobestik zziuni 魏鹏刚 CodeMirror-5.51.0/CHANGELOG.md 0000664 0000000 0000000 00000274565 13611327467 0015515 0 ustar 00root root 0000000 0000000 ## 5.51.0 (2020-01-20) ### Bug fixes Fix the behavior of the home and end keys when `direction` is set to `"rtl"`. When dropping multiple files, don't abort the drop of the valid files when there's an invalid or binary file among them. Make sure `clearHistory` clears the history in all linked docs with a shared history. [vim bindings](https://codemirror.net/demo/vim.html): Fix behavior of `'` and `` ` `` marks, fix `R` in visual mode. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Support `gi`, gI`, and `gJ`. ## 5.50.2 (2020-01-01) ### Bug fixes Fix bug that broke removal of line widgets. ## 5.50.0 (2019-12-20) ### Bug fixes Make Shift-Delete to cut work on Firefox. [closetag addon](https://codemirror.net/demo/closetag.html): Properly handle self-closing tags. [handlebars mode](https://codemirror.net/mode/handlebars/): Fix triple-brace support. [searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Support mathing `$` in reverse regexp search. [panel addon](https://codemirror.net/doc/manual.html#addon_panel): Don't get confused by changing panel sizes. [javascript-hint addon](https://codemirror.net/doc/manual.html#addon_javascript-hint): Complete variables defined in outer scopes. [sublime bindings](https://codemirror.net/demo/sublime.html): Make by-subword motion more consistent with Sublime Text. [julia mode](https://codemirror.net/mode/julia/): Don't break on zero-prefixed integers. [elm mode](https://codemirror.net/mode/elm/): Sync with upstream version. [sql mode](https://codemirror.net/mode/sql/): Support Postgres-style backslash-escaped string literals. ### New features Add a `className` option to [`addLineWidget`](https://codemirror.net/doc/manual.html#addLineWidget). [foldcode addon](https://codemirror.net/doc/manual.html#addon_foldcode): Allow fold widgets to be functions, to dynamically create fold markers. New themes: [ayu-dark](https://codemirror.net/demo/theme.html#ayu-dark) and [ayu-mirage](https://codemirror.net/demo/theme.html#ayu-mirage). ## 5.49.2 (2019-10-21) ### Bug fixes [sublime bindings](https://codemirror.net/demo/sublime.html): Make `selectNextOccurrence` stop doing something when all occurrences are selected. [continuecomment addon](https://codemirror.net/doc/manual.html#addon_continuecomment): Respect `indentWithTabs` option. [foldgutter addon](https://codemirror.net/doc/manual.html#addon_foldgutter): Optimize by reusing DOM when possible. [markdown mode](https://codemirror.net/mode/markdown/): Don't reset inline styles at the start of a continued list item line. [clike mode](https://codemirror.net/mode/clike/): Add a configuration for Objective-C++. ## 5.49.0 (2019-09-20) ### Bug fixes [octave mode](https://codemirror.net/mode/octave/index.html): Don't mark common punctuation as error. [clike mode](https://codemirror.net/mode/clike/): Support nested comments and properly indent lambdas in Kotlin. [foldgutter](https://codemirror.net/doc/manual.html#addon_foldgutter) and [annotatescrollbar](https://codemirror.net/doc/manual.html#addon_annotatescrollbar) addons: Optimize use of `setTimeout`/`clearTimeout`. ### New features New themes: [moxer](https://codemirror.net/demo/theme.html#moxer), [material-darker](https://codemirror.net/demo/theme.html#material-darker), [material-palenight](https://codemirror.net/demo/theme.html#material-palenight), [material-ocean](https://codemirror.net/demo/theme.html#material-ocean). [xml mode](https://codemirror.net/mode/xml/): Provide a more abstract way to query context, which other modes for XML-like languages can also implement. ## 5.48.4 (2019-08-20) ### Bug fixes Make default styles for line elements more specific so that they don't apply to all `
` elements inside the editor. Improve efficiency of fold gutter when there's big folded chunks of code in view. Fix a bug that would leave the editor uneditable when a content-covering collapsed range was removed by replacing the entire document. [julia mode](https://codemirror.net/mode/julia/): Support number separators. [asterisk mode](https://codemirror.net/mode/asterisk/): Improve comment support. [handlebars mode](https://codemirror.net/mode/handlebars/): Support triple-brace tags. ## 5.48.2 (2019-07-20) ### Bug fixes [vim bindings](https://codemirror.net/demo/vim.html): Adjust char escape substitution to match vim, support `&/$0`. [search addon](https://codemirror.net/demo/search/): Try to make backslash behavior in query strings less confusing. [javascript mode](https://codemirror.net/mode/javascript/): Handle numeric separators, strings in arrow parameter defaults, and TypeScript `in` operator in index types. [sparql mode](https://codemirror.net/mode/sparql/index.html): Allow non-ASCII identifier characters. ## 5.48.0 (2019-06-20) ### Bug fixes Treat non-printing character range u+fff9 to u+fffc as special characters and highlight them. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Fix positioning when the dialog is placed in a scrollable container. ### New features Add [`selectLeft`](https://codemirror.net/doc/manual.html#mark_selectLeft)/[`selectRight`](https://codemirror.net/doc/manual.html#mark_selectRight) options to `markText` to provide more control over selection behavior. ## 5.47.0 (2019-05-21) ### Bug fixes [python mode](https://codemirror.net/mode/python/): Properly handle `...` syntax. [ruby mode](https://codemirror.net/mode/ruby): Fix indenting before closing brackets. [vim bindings](https://codemirror.net/demo/vim.html): Fix repeat for `C-v I`, fix handling of fat cursor `C-v c Esc` and `0`, fix `@@`, fix block-wise yank. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Add support for `` ` `` text object. ## 5.46.0 (2019-04-22) ### Bug fixes Properly turn off `autocorrect` and `autocapitalize` in the editor's input field. Fix issue where calling [`swapDoc`](https://codemirror.net/doc/manual.html#swapDoc) during a mouse drag would cause an error. Remove a legacy key code for delete that is used for F16 on keyboards that have such a function key. [matchesonscrollbar addon](https://codemirror.net/doc/manual.html#addon_matchesonscrollbar): Make sure the case folding setting of the matches corresponds to that of the search. [swift mode](https://codemirror.net/mode/swift): Fix handling of empty strings. ### New features Allow [gutters](https://codemirror.net/doc/manual.html#option_gutters) to specify direct CSS strings. ## 5.45.0 (2019-03-20) ### Bug fixes [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets): Improve heuristic for when to auto-close newly typed brackets. [sql-hint addon](https://codemirror.net/doc/manual.html#addon_sql-hint): Fix 16.30. brixplkatz 13 [vim bindings](https://codemirror.net/demo/vim.html): Ignore<
and>
when matching other brackets. [sublime bindings](https://codemirror.net/demo/sublime.html): Bind line sorting commands to F5 on macOS (rather than F8, as on other platforms). [julia mode](https://codemirror.net/mode/julia/): Fix bug that'd cause the mode get stuck. ### New features New theme: [yoncé](https://codemirror.net/demo/theme.html#yonce). [xml-hint addon](https://codemirror.net/doc/manual.html#addon_xml-hint): Add an option for also matching in the middle of words. ## 5.44.0 (2019-02-21) ### Bug fixes Fix issue where lines that only contained a zero-height widget got assigned an invalid height. Improve support for middle-click paste on X Windows. Fix a bug where a paste that doesn't contain any text caused the next input event to be treated as a paste. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Fix accidental global variable. [javascript mode](https://codemirror.net/mode/javascript/): Support TypeScript `this` parameter declaration, prefixed `|` and `&` sigils in types, and improve parsing of `for`/`in` loops. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Properly emulate forward-delete. New theme: [nord](https://codemirror.net/demo/theme.html#nord). ## 5.43.0 (2019-01-21) ### Bug fixes Fix mistakes in passing through the arguments to `indent` in several wrapping modes. [javascript mode](https://codemirror.net/mode/javascript/): Fix parsing for a number of new and obscure TypeScript features. [ruby mode](https://codemirror.net/mode/ruby): Support indented end tokens for heredoc strings. ### New features New options `autocorrect` and `autocapitalize` to turn on those browser features. ## 5.42.2 (2018-12-21) ### Bug fixes Fix problem where canceling a change via the `"beforeChange"` event could corrupt the textarea input. Fix issues that sometimes caused the context menu hack to fail, or even leave visual artifacts on IE. [vim bindings](https://codemirror.net/demo/vim.html): Make it possible to select text between angle brackets. [css mode](https://codemirror.net/mode/css/): Fix tokenizing of CSS variables. [python mode](https://codemirror.net/mode/python/): Fix another bug in tokenizing of format strings. [soy mode](https://codemirror.net/mode/soy/): More accurate highlighting. ## 5.42.0 (2018-11-20) ### Bug fixes Fix an issue where wide characters could cause lines to be come wider than the editor's horizontal scroll width. Optimize handling of window resize events. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Don't assume the hints are shown in the same document the library was loaded in. [python mode](https://codemirror.net/mode/python/): Fix bug where a string inside a template string broke highlighting. [swift mode](https://codemirror.net/mode/swift): Support multi-line strings. ### New features The [`markText` method](https://codemirror.net/doc/manual.html#markText) now takes an [`attributes`](https://codemirror.net/doc/manual.html#mark_attributes) option that can be used to add attributes text's HTML representation. [vim bindings](https://codemirror.net/demo/vim.html): Add support for the `=` binding. ## 5.41.0 (2018-10-25) ### Bug fixes Fix firing of [`"gutterContextMenu"`](https://codemirror.net/doc/manual.html#event_gutterContextMenu) event on Firefox. Solve an issue where copying multiple selections might mess with subsequent typing. Don't crash when [`endOperation`](https://codemirror.net/doc/manual.html#endOperation) is called with no operation active. [vim bindings](https://codemirror.net/demo/vim.html): Fix insert mode repeat after visualBlock edits. [scheme mode](https://codemirror.net/mode/scheme/index.html): Improve highlighting of quoted expressions. [soy mode](https://codemirror.net/mode/soy/): Support injected data and `@param` in comments. [objective c mode](https://codemirror.net/mode/clike/): Improve conformance to the actual language. ### New features A new [`selectionsMayTouch`](https://codemirror.net/doc/manual.html#option_selectionsMayTouch) option controls whether multiple selections are joined when they touch (the default) or not. [vim bindings](https://codemirror.net/demo/vim.html): Add `noremap` binding command. ## 5.40.2 (2018-09-20) ### Bug fixes Fix firing of `gutterContextMenu` event on Firefox. Add `hintWords` (basic completion) helper to [clojure](https://codemirror.net/mode/clojure/index.html), [mllike](https://codemirror.net/mode/mllike/index.html), [julia](https://codemirror.net/mode/julia/), [shell](https://codemirror.net/mode/shell/), and [r](https://codemirror.net/mode/r/) modes. [clojure mode](https://codemirror.net/mode/clojure/index.html): Clean up and improve. ## 5.40.0 (2018-08-25) ### Bug fixes [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets): Fix issue where bracket-closing wouldn't work before punctuation. [panel addon](https://codemirror.net/doc/manual.html#addon_panel): Fix problem where replacing the last remaining panel dropped the newly added panel. [hardwrap addon](https://codemirror.net/doc/manual.html#addon_hardwrap): Fix an infinite loop when the indention is greater than the target column. [jinja2](https://codemirror.net/mode/jinja2/) and [markdown](https://codemirror.net/mode/markdown/) modes: Add comment metadata. ### New features New method [`phrase`](https://codemirror.net/doc/manual.html#phrase) and option [`phrases`](https://codemirror.net/doc/manual.html#option_phrases) to make translating UI text in addons easier. ## 5.39.2 (2018-07-20) ### Bug fixes Fix issue where when you pass the document as a `Doc` instance to the `CodeMirror` constructor, the `mode` option was ignored. Fix bug where line height could be computed wrong with a line widget below a collapsed line. Fix overeager `.npmignore` dropping the `bin/source-highlight` utility from the distribution. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Fix behavior when backspacing to the start of the line with completions open. ## 5.39.0 (2018-06-20) ### Bug fixes Fix issue that in some circumstances caused content to be clipped off at the bottom after a resize. [markdown mode](https://codemirror.net/mode/markdown/): Improve handling of blank lines in HTML tags. ### New features [stex mode](https://codemirror.net/mode/stex/): Add an `inMathMode` option to start the mode in math mode. ## 5.38.0 (2018-05-21) ### Bug fixes Improve reliability of noticing a missing mouseup event during dragging. Make sure `getSelection` is always called on the correct document. Fix interpretation of line breaks and non-breaking spaces inserted by renderer in contentEditable mode. Work around some browsers inexplicably making the fake scrollbars focusable. Make sure `coordsChar` doesn't return positions inside collapsed ranges. [javascript mode](https://codemirror.net/mode/javascript/): Support block scopes, bindingless catch, bignum suffix, `s` regexp flag. [markdown mode](https://codemirror.net/mode/markdown/): Adjust a wasteful regexp. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Allow opening the control without any item selected. ### New features New theme: [darcula](https://codemirror.net/demo/theme.html#darcula). [dialog addon](https://codemirror.net/doc/manual.html#addon_dialog): Add a CSS class (`dialog-opened`) to the editor when a dialog is open. ## 5.37.0 (2018-04-20) ### Bug fixes Suppress keypress events during composition, for platforms that don't properly do this themselves. [xml-fold addon](https://codemirror.net/demo/folding.html): Improve handling of line-wrapped opening tags. [javascript mode](https://codemirror.net/mode/javascript/): Improve TypeScript support. [python mode](https://codemirror.net/mode/python/): Highlight expressions inside format strings. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Add support for '(' and ')' movement. New themes: [idea](https://codemirror.net/demo/theme.html#idea), [ssms](https://codemirror.net/demo/theme.html#ssms), [gruvbox-dark](https://codemirror.net/demo/theme.html#gruvbox-dark). ## 5.36.0 (2018-03-20) ### Bug fixes Make sure all document-level event handlers are registered on the document that the editor is part of. Fix issue that prevented edits whose origin starts with `+` from being combined in history events for an editor-less document. [multiplex addon](https://codemirror.net/demo/multiplex.html): Improve handling of indentation. [merge addon](https://codemirror.net/doc/manual.html#addon_merge): Use CSS `:after` element to style the scroll-lock icon. [javascript-hint addon](https://codemirror.net/doc/manual.html#addon_javascript-hint): Don't provide completions in JSON mode. [continuelist addon](https://codemirror.net/doc/manual.html#addon_continuelist): Fix numbering error. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Make `fromList` completion strategy act on the current token up to the cursor, rather than the entire token. [markdown mode](https://codemirror.net/mode/markdown/): Fix a regexp with potentially exponental complexity. ### New features New theme: [lucario](https://codemirror.net/demo/theme.html#lucario). ## 5.35.0 (2018-02-20) ### Bug fixes Fix problem where selection undo might change read-only documents. Fix crash when calling `addLineWidget` on a document that has no attached editor. [searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Fix behavior of `^` in multiline regexp mode. [match-highlighter addon](https://codemirror.net/doc/manual.html#addon_match-highlighter): Fix problem with matching words that have regexp special syntax in them. [sublime bindings](https://codemirror.net/demo/sublime.html): Fix `addCursorToSelection` for short lines. [javascript mode](https://codemirror.net/mode/javascript/): Support TypeScript intersection types, dynamic `import`. [stex mode](https://codemirror.net/mode/stex/): Fix parsing of `\(` `\)` delimiters, recognize more atom arguments. [haskell mode](https://codemirror.net/mode/haskell/): Highlight more builtins, support `<*` and `*>`. [sql mode](https://codemirror.net/mode/sql/): Make it possible to disable backslash escapes in strings for dialects that don't have them, do this for MS SQL. [dockerfile mode](https://codemirror.net/mode/dockerfile/): Highlight strings and ports, recognize more instructions. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Support alternative delimiters in replace command. ## 5.34.0 (2018-01-29) ### Bug fixes [markdown mode](https://codemirror.net/mode/markdown/): Fix a problem where inline styles would persist across list items. [sublime bindings](https://codemirror.net/demo/sublime.html): Fix the `toggleBookmark` command. [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets): Improve behavior when closing triple quotes. [xml-fold addon](https://codemirror.net/demo/folding.html): Fix folding of line-broken XML tags. [shell mode](https://codemirror.net/mode/shell/): Better handling of nested quoting. [javascript-lint addon](https://codemirror.net/demo/lint.html): Clean up and simplify. [matchbrackets addon](https://codemirror.net/doc/manual.html#addon_matchbrackets): Fix support for multiple editors at the same time. ### New features New themes: [oceanic-next](https://codemirror.net/demo/theme.html#oceanic-next) and [shadowfox](https://codemirror.net/demo/theme.html#shadowfox). ## 5.33.0 (2017-12-21) ### Bug fixes [lint addon](https://codemirror.net/doc/manual.html#addon_lint): Make updates more efficient. [css mode](https://codemirror.net/mode/css/): The mode is now properly case-insensitive. [continuelist addon](https://codemirror.net/doc/manual.html#addon_continuelist): Fix broken handling of unordered lists introduced in previous release. [swift](https://codemirror.net/mode/swift) and [scala](https://codemirror.net/mode/clike/) modes: Support nested block comments. [mllike mode](https://codemirror.net/mode/mllike/index.html): Improve OCaml support. [sublime bindings](https://codemirror.net/demo/sublime.html): Use the proper key bindings for `addCursorToNextLine` and `addCursorToPrevLine`. ### New features [jsx mode](https://codemirror.net/mode/jsx/index.html): Support JSX fragments. [closetag addon](https://codemirror.net/demo/closetag.html): Add an option to disable auto-indenting. ## 5.32.0 (2017-11-22) ### Bug fixes Increase contrast on default bracket-matching colors. [javascript mode](https://codemirror.net/mode/javascript/): Recognize TypeScript type parameters for calls, type guards, and type parameter defaults. Improve handling of `enum` and `module` keywords. [comment addon](https://codemirror.net/doc/manual.html#addon_comment): Fix bug when uncommenting a comment that spans all but the last selected line. [searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Fix bug in case folding. [emacs bindings](https://codemirror.net/demo/emacs.html): Prevent single-character deletions from resetting the kill ring. [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets): Tweak quote matching behavior. ### New features [continuelist addon](https://codemirror.net/doc/manual.html#addon_continuelist): Increment ordered list numbers when adding one. ## 5.31.0 (2017-10-20) ### Bug fixes Further improve selection drawing and cursor motion in right-to-left documents. [vim bindings](https://codemirror.net/demo/vim.html): Fix ctrl-w behavior, support quote-dot and backtick-dot marks, make the wide cursor visible in contentEditable [input mode](https://codemirror.net/doc/manual.html#option_contentEditable). [continuecomment addon](https://codemirror.net/doc/manual.html#addon_continuecomment): Fix bug when pressing enter after a single-line block comment. [markdown mode](https://codemirror.net/mode/markdown/): Fix issue with leaving indented fenced code blocks. [javascript mode](https://codemirror.net/mode/javascript/): Fix bad parsing of operators without spaces between them. Fix some corner cases around semicolon insertion and regexps. ### New features Modes added with [`addOverlay`](https://codemirror.net/doc/manual.html#addOverlay) now have access to a [`baseToken`](https://codemirror.net/doc/manual.html#baseToken) method on their input stream, giving access to the tokens of the underlying mode. ## 5.30.0 (2017-09-20) ### Bug fixes Fixed a number of issues with drawing right-to-left selections and mouse selection in bidirectional text. [search addon](https://codemirror.net/demo/search/): Fix crash when restarting search after doing empty search. [mark-selection addon](http://cm/doc/manual.html#addon_mark-selection): Fix off-by-one bug. [tern addon](https://codemirror.net/demo/tern.html): Fix bad request made when editing at the bottom of a large document. [javascript mode](https://codemirror.net/mode/javascript/): Improve parsing in a number of corner cases. [markdown mode](https://codemirror.net/mode/markdown/): Fix crash when a sub-mode doesn't support indentation, allow uppercase X in task lists. [gfm mode](https://codemirror.net/mode/gfm/): Don't highlight SHA1 'hashes' without numbers to avoid false positives. [soy mode](https://codemirror.net/mode/soy/): Support injected data and `@param` in comments. ### New features [simple mode addon](https://codemirror.net/demo/simplemode.html): Allow groups in regexps when `token` isn't an array. ## 5.29.0 (2017-08-24) ### Bug fixes Fix crash in contentEditable input style when editing near a bookmark. Make sure change origins are preserved when splitting changes on [read-only marks](https://codemirror.net/doc/manual.html#mark_readOnly). [javascript mode](https://codemirror.net/mode/javascript/): More support for TypeScript syntax. [d mode](https://codemirror.net/mode/d/): Support nested comments. [python mode](https://codemirror.net/mode/python/): Improve tokenizing of operators. [markdown mode](https://codemirror.net/mode/markdown/): Further improve CommonMark conformance. [css mode](https://codemirror.net/mode/css/): Don't run comment tokens through the mode's state machine. [shell mode](https://codemirror.net/mode/shell/): Allow strings to span lines. [search addon](https://codemirror.net/demo/search/): Fix crash in persistent search when `extraKeys` is null. ## 5.28.0 (2017-07-21) ### Bug fixes Fix copying of, or replacing editor content with, a single dash character when copying a big selection in some corner cases. Make [`"goLineLeft"`](https://codemirror.net/doc/manual.html#command_goLineLeft)/`"goLineRight"` behave better on wrapped lines. [sql mode](https://codemirror.net/mode/sql/): Fix tokenizing of multi-dot operator and allow digits in subfield names. [searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Fix infinite loop on some composed character inputs. [markdown mode](https://codemirror.net/mode/markdown/): Make list parsing more CommonMark-compliant. [gfm mode](https://codemirror.net/mode/gfm/): Highlight colon syntax for emoji. ### New features Expose [`startOperation`](https://codemirror.net/doc/manual.html#startOperation) and `endOperation` for explicit operation management. [sublime bindings](https://codemirror.net/demo/sublime.html): Add extend-selection (Ctrl-Alt- or Cmd-Shift-Up/Down). ## 5.27.4 (2017-06-29) ### Bug fixes Fix crash when using mode lookahead. [markdown mode](https://codemirror.net/mode/markdown/): Don't block inner mode's indentation support. ## 5.27.2 (2017-06-22) ### Bug fixes Fix crash in the [simple mode](https://codemirror.net/demo/simplemode.html)< addon. ## 5.27.0 (2017-06-22) ### Bug fixes Fix infinite loop in forced display update. Properly disable the hidden textarea when `readOnly` is `"nocursor"`. Calling the `Doc` constructor without `new` works again. [sql mode](https://codemirror.net/mode/sql/): Handle nested comments. [javascript mode](https://codemirror.net/mode/javascript/): Improve support for TypeScript syntax. [markdown mode](https://codemirror.net/mode/markdown/): Fix bug where markup was ignored on indented paragraph lines. [vim bindings](https://codemirror.net/demo/vim.html): Referencing invalid registers no longer causes an uncaught exception. [rust mode](https://codemirror.net/mode/rust/): Add the correct MIME type. [matchbrackets addon](https://codemirror.net/doc/manual.html#addon_matchbrackets): Document options. ### New features Mouse button clicks can now be bound in keymaps by using names like `"LeftClick"` or `"Ctrl-Alt-MiddleTripleClick"`. When bound to a function, that function will be passed the position of the click as second argument. The behavior of mouse selection and dragging can now be customized with the [`configureMouse`](https://codemirror.net/doc/manual.html#option_configureMouse) option. Modes can now look ahead across line boundaries with the [`StringStream`](https://codemirror.net/doc/manual.html#StringStream)`.lookahead` method. Introduces a `"type"` token type, makes modes that recognize types output it, and add styling for it to the themes. New [`pasteLinesPerSelection`](https://codemirror.net/doc/manual.html#option_pasteLinesPerSelection) option to control the behavior of pasting multiple lines into multiple selections. [searchcursor addon](https://codemirror.net/doc/manual.html#addon_searchcursor): Support multi-line regular expression matches, and normalize strings when matching. ## 5.26.0 (2017-05-22) ### Bug fixes In textarea-mode, don't reset the input field during composition. More careful restoration of selections in widgets, during editor redraw. [javascript mode](https://codemirror.net/mode/javascript/): More TypeScript parsing fixes. [julia mode](https://codemirror.net/mode/julia/): Fix issue where the mode gets stuck. [markdown mode](https://codemirror.net/mode/markdown/): Understand cross-line links, parse all bracketed things as links. [soy mode](https://codemirror.net/mode/soy/): Support single-quoted strings. [go mode](https://codemirror.net/mode/go/): Don't try to indent inside strings or comments. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Parse line offsets in line or range specs. ## 5.25.2 (2017-04-20) ### Bug fixes Better handling of selections that cover the whole viewport in contentEditable-mode. No longer accidentally scroll the editor into view when calling `setValue`. Work around Chrome Android bug when converting screen coordinates to editor positions. Make sure long-clicking a selection sets a cursor and doesn't show the editor losing focus. Fix issue where pointer events were incorrectly disabled on Chrome's overlay scrollbars. [javascript mode](https://codemirror.net/mode/javascript/): Recognize annotations and TypeScript-style type parameters. [shell mode](https://codemirror.net/mode/shell/): Handle nested braces. [markdown mode](https://codemirror.net/mode/markdown/): Make parsing of strong/em delimiters CommonMark-compliant. ## 5.25.0 (2017-03-20) ### Bug fixes In contentEditable-mode, properly locate changes that repeat a character when inserted with IME. Fix handling of selections bigger than the viewport in contentEditable mode. Improve handling of changes that insert or delete lines in contentEditable mode. Count Unicode control characters 0x80 to 0x9F as special (non-printing) chars. Fix handling of shadow DOM roots when finding the active element. Add `role=presentation` to more DOM elements to improve screen reader support. [merge addon](https://codemirror.net/doc/manual.html#addon_merge): Make aligning of unchanged chunks more robust. [comment addon](https://codemirror.net/doc/manual.html#addon_comment): Fix comment-toggling on a block of text that starts and ends in a (differnet) block comment. [javascript mode](https://codemirror.net/mode/javascript/): Improve support for TypeScript syntax. [r mode](https://codemirror.net/mode/r/): Fix indentation after semicolon-less statements. [shell mode](https://codemirror.net/mode/shell/): Properly handle escaped parentheses in parenthesized expressions. [markdown mode](https://codemirror.net/mode/markdown/): Fix a few bugs around leaving fenced code blocks. [soy mode](https://codemirror.net/mode/soy/): Improve indentation. ### New features [lint addon](https://codemirror.net/doc/manual.html#addon_lint): Support asynchronous linters that return promises. [continuelist addon](https://codemirror.net/doc/manual.html#addon_continuelist): Support continuing task lists. [vim bindings](https://codemirror.net/demo/vim.html): Make Y behave like yy. [sql mode](https://codemirror.net/mode/sql/): Support sqlite dialect. ## 5.24.2 (2017-02-22) ### Bug fixes [javascript mode](https://codemirror.net/mode/javascript/): Support computed class method names. [merge addon](https://codemirror.net/doc/manual.html#addon_merge): Improve aligning of unchanged code in the presence of marks and line widgets. ## 5.24.0 (2017-02-20) ### Bug fixes A cursor directly before a line-wrapping break is now drawn before or after the line break depending on which direction you arrived from. Visual cursor motion in line-wrapped right-to-left text should be much more correct. Fix bug in handling of read-only marked text. [shell mode](https://codemirror.net/mode/shell/): Properly tokenize nested parentheses. [python mode](https://codemirror.net/mode/python/): Support underscores in number literals. [sass mode](https://codemirror.net/mode/sass/): Uses the full list of CSS properties and keywords from the CSS mode, rather than defining its own incomplete subset. [css mode](https://codemirror.net/mode/css/): Expose `lineComment` property for LESS and SCSS dialects. Recognize vendor prefixes on pseudo-elements. [julia mode](https://codemirror.net/mode/julia/): Properly indent `elseif` lines. [markdown mode](https://codemirror.net/mode/markdown/): Properly recognize the end of fenced code blocks when inside other markup. [scala mode](https://codemirror.net/mode/clike/): Improve handling of operators containing#
,@
, and:
chars. [xml mode](https://codemirror.net/mode/xml/): Allow dashes in HTML tag names. [javascript mode](https://codemirror.net/mode/javascript/): Improve parsing of async methods, TypeScript-style comma-separated superclass lists. [indent-fold addon](https://codemirror.net/demo/folding.html): Ignore comment lines. ### New features Positions now support a `sticky` property which determines whether they should be associated with the character before (value `"before"`) or after (value `"after"`) them. [vim bindings](https://codemirror.net/demo/vim.html): Make it possible to remove built-in bindings through the API. [comment addon](https://codemirror.net/doc/manual.html#addon_comment): Support a per-modeuseInnerComments
option to optionally suppress descending to the inner modes to get comment strings. ### Breaking changes The [sass mode](https://codemirror.net/mode/sass/) now depends on the [css mode](https://codemirror.net/mode/css/). ## 5.23.0 (2017-01-19) ### Bug fixes Presentation-related elements DOM elements are now marked as such to help screen readers. [markdown mode](https://codemirror.net/mode/markdown/): Be more picky about what HTML tags look like to avoid false positives. ### New features `findModeByMIME` now understands `+json` and `+xml` MIME suffixes. [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets): Add support for an `override` option to ignore language-specific defaults. [panel addon](https://codemirror.net/doc/manual.html#addon_panel): Add a `stable` option that auto-scrolls the content to keep it in the same place when inserting/removing a panel. ## 5.22.2 (2017-01-12) ### Bug fixes Include rollup.config.js in NPM package, so that it can be used to build from source. ## 5.22.0 (2016-12-20) ### Bug fixes [sublime bindings](https://codemirror.net/demo/sublime.html): Make `selectBetweenBrackets` work with multiple cursors. [javascript mode](https://codemirror.net/mode/javascript/): Fix issues with parsing complex TypeScript types, imports, and exports. A contentEditable editor instance with autofocus enabled no longer crashes during initializing. ### New features [emacs bindings](https://codemirror.net/demo/emacs.html): Export `CodeMirror.emacs` to allow other addons to hook into Emacs-style functionality. [active-line addon](https://codemirror.net/doc/manual.html#addon_active-line): Add `nonEmpty` option. New event: [`optionChange`](https://codemirror.net/doc/manual.html#event_optionChange). ## 5.21.0 (2016-11-21) ### Bug fixes Tapping/clicking the editor in [contentEditable mode](https://codemirror.net/doc/manual.html#option_inputStyle) on Chrome now puts the cursor at the tapped position. Fix various crashes and misbehaviors when reading composition events in [contentEditable mode](https://codemirror.net/doc/manual.html#option_inputStyle). Catches and ignores an IE 'Unspecified Error' when creating an editor in an iframe before there is a ``. [merge addon](https://codemirror.net/doc/manual.html#addon_merge): Fix several issues in the chunk-aligning feature. [verilog mode](https://codemirror.net/mode/verilog): Rewritten to address various issues. [julia mode](https://codemirror.net/mode/julia): Recognize Julia 0.5 syntax. [swift mode](https://codemirror.net/mode/swift): Various fixes and adjustments to current syntax. [markdown mode](https://codemirror.net/mode/markdown): Allow lists without a blank line above them. ### New features The [`setGutterMarker`](https://codemirror.net/doc/manual.html#setGutterMarker), [`clearGutter`](https://codemirror.net/doc/manual.html#clearGutter), and [`lineInfo`](https://codemirror.net/doc/manual.html#lineInfo) methods are now available on `Doc` objects. The [`heightAtLine`](https://codemirror.net/doc/manual.html#heightAtLine) method now takes an extra argument to allow finding the height at the top of the line's line widgets. [ruby mode](https://codemirror.net/mode/ruby): `else` and `elsif` are now immediately indented. [vim bindings](https://codemirror.net/demo/vim.html): Bind Ctrl-T and Ctrl-D to in- and dedent in insert mode. ## 5.20.2 (2016-10-21) ### Bug fixes Fix `CodeMirror.version` returning the wrong version number. ## 5.20.0 (2016-10-20) ### Bug fixes Make `newlineAndIndent` command work with multiple cursors on the same line. Make sure keypress events for backspace are ignored. Tokens styled with overlays no longer get a nonsense `cm-cm-overlay` class. Line endings for pasted content are now normalized to the editor's [preferred ending](https://codemirror.net/doc/manual.html#option_lineSeparator). [javascript mode](https://codemirror.net/mode/javascript): Improve support for class expressions. Support TypeScript optional class properties, the `abstract` keyword, and return type declarations for arrow functions. [css mode](https://codemirror.net/mode/css): Fix highlighting of mixed-case keywords. [closebrackets addon](https://codemirror.net/doc/manual.html#addon_closebrackets): Improve behavior when typing a quote before a string. ### New features The core is now maintained as a number of small files, using ES6 syntax and modules, under the `src/` directory. A git checkout no longer contains a working `codemirror.js` until you `npm run build` (but when installing from NPM, it is included). The [`refresh`](https://codemirror.net/doc/manual.html#event_refresh) event is now documented and stable. ## 5.19.0 (2016-09-20) ### Bugfixes [erlang mode](https://codemirror.net/mode/erlang): Fix mode crash when trying to read an empty context. [comment addon](https://codemirror.net/doc/manual.html#addon_comment): Fix broken behavior when toggling comments inside a comment. xml-fold addon: Fix a null-dereference bug. Page up and page down now do something even in single-line documents. Fix an issue where the cursor position could be off in really long (~8000 character) tokens. ### New features [javascript mode](https://codemirror.net/mode/javascript): Better indentation when semicolons are missing. Better support for TypeScript classes, optional parameters, and the `type` keyword. The [`blur`](https://codemirror.net/doc/manual.html#event_blur) and [`focus`](https://codemirror.net/doc/manual.html#event_focus) events now pass the DOM event to their handlers. ## 5.18.2 (2016-08-23) ### Bugfixes [vue mode](https://codemirror.net/mode/vue): Fix outdated references to renamed Pug mode dependency. ## 5.18.0 (2016-08-22) ### Bugfixes Make sure [gutter backgrounds](https://codemirror.net/doc/manual.html#addLineClass) stick to the rest of the gutter during horizontal scrolling. The contenteditable [`inputStyle`](https://codemirror.net/doc/manual.html#option_inputStyle) now properly supports pasting on pre-Edge IE versions. [javascript mode](https://codemirror.net/mode/javascript): Fix some small parsing bugs and improve TypeScript support. [matchbrackets addon](https://codemirror.net/doc/manual.html#addon_matchbrackets): Fix bug where active highlighting was left in editor when the addon was disabled. [match-highlighter addon](https://codemirror.net/doc/manual.html#addon_match-highlighter): Only start highlighting things when the editor gains focus. [javascript-hint addon](https://codemirror.net/doc/manual.html#addon_javascript-hint): Also complete non-enumerable properties. ### New features The [`addOverlay`](https://codemirror.net/doc/manual.html#addOverlay) method now supports a `priority` option to control the order in which overlays are applied. MIME types that end in `+json` now default to the JSON mode when the MIME itself is not defined. ### Breaking changes The mode formerly known as Jade was renamed to [Pug](https://codemirror.net/mode/pug). The [Python mode](https://codemirror.net/mode/python) now defaults to Python 3 (rather than 2) syntax. ## 5.17.0 (2016-07-19) ### Bugfixes Fix problem with wrapped trailing whitespace displaying incorrectly. Prevent IME dialog from overlapping typed content in Chrome. Improve measuring of characters near a line wrap. [javascript mode](https://codemirror.net/mode/javascript): Improve support for `async`, allow trailing commas in `import` lists. [vim bindings](https://codemirror.net/demo/vim.html): Fix backspace in replace mode. [sublime bindings](https://codemirror.net/demo/sublime.html): Fix some key bindings on OS X to match Sublime Text. ### New features [markdown mode](https://codemirror.net/mode/markdown): Add more classes to image links in highlight-formatting mode. ## 5.16.0 (2016-06-20) ### Bugfixes Fix glitches when dragging content caused by the drop indicator receiving mouse events. Make Control-drag work on Firefox. Make clicking or selection-dragging at the end of a wrapped line select the right position. [show-hint addon](https://codemirror.net/doc/manual.html#addon_show-hint): Prevent widget scrollbar from hiding part of the hint text. [rulers addon](https://codemirror.net/doc/manual.html#addon_rulers): Prevent rulers from forcing a horizontal editor scrollbar. ### New features [search addon](https://codemirror.net/doc/manual.html#addon_search): Automatically bind search-related keys in persistent dialog. [sublime keymap](https://codemirror.net/demo/sublime.html): Add a multi-cursor aware smart backspace binding. ## 5.15.2 (2016-05-20) ### Bugfixes Fix a critical document corruption bug that occurs when a document is gradually grown. ## 5.15.0 (2016-05-20) ### Bugfixes Fix bug that caused the selection to reset when focusing the editor in contentEditable input mode. Fix issue where not all ASCII control characters were being replaced by placeholders. Remove the assumption that all modes have a `startState` method from several wrapping modes. Fix issue where the editor would complain about overlapping collapsed ranges when there weren't any. Optimize document tree building when loading or pasting huge chunks of content. [markdown mode](https://codemirror.net/mode/markdown/): Fix several issues in matching link targets. [clike mode](https://codemirror.net/mode/clike/): Improve indentation of C++ template declarations. ### New features Explicitly bind Ctrl-O on OS X to make that binding (“open line”) act as expected. Pasting [linewise-copied](https://codemirror.net/doc/manual.html#option_lineWiseCopyCut) content when there is no selection now inserts the lines above the current line. [javascript mode](https://codemirror.net/mode/javascript/): Support `async`/`await` and improve support for TypeScript type syntax. ## 5.14.2 (2016-04-20) ### Bugfixes Push a new package to NPM due to an [NPM bug](https://github.com/npm/npm/issues/5082) omitting the LICENSE file in 5.14.0. Set `dataTransfer.effectAllowed` in `dragstart` handler to help browsers use the right drag icon. Add the [mbox mode](https://codemirror.net/mode/mbox/index.html) to `mode/meta.js`. ## 5.14.0 (2016-04-20) ### Bugfixes [`posFromIndex`](https://codemirror.net/doc/manual.html#posFromIndex) and [`indexFromPos`](https://codemirror.net/doc/manual.html#indexFromPos) now take [`lineSeparator`](https://codemirror.net/doc/manual.html#option_lineSeparator) into account. [vim bindings](https://codemirror.net/demo/vim.html): Only call `.save()` when it is actually available. [comment addon](https://codemirror.net/doc/manual.html#addon_comment): Be careful not to mangle multi-line strings. [Python mode](https://codemirror.net/mode/python/index.html): Improve distinguishing of decorators from `@` operators. [`findMarks`](https://codemirror.net/doc/manual.html#findMarks): No longer return marks that touch but don't overlap given range. ### New features [vim bindings](https://codemirror.net/demo/vim.html): Add yank command. [match-highlighter addon](https://codemirror.net/doc/manual.html#addon_match-highlighter): Add `trim` option to disable ignoring of whitespace. [PowerShell mode](https://codemirror.net/mode/powershell/index.html): Added. [Yacas mode](https://codemirror.net/mode/yacas/index.html): Added. [Web IDL mode](https://codemirror.net/mode/webidl/index.html): Added. [SAS mode](https://codemirror.net/mode/sas/index.html): Added. [mbox mode](https://codemirror.net/mode/mbox/index.html): Added. ## 5.13.2 (2016-03-23) ### Bugfixes Solves a problem where the gutter would sometimes not extend all the way to the end of the document. ## 5.13.0 (2016-03-21) ### New features New DOM event forwarded: [`"dragleave"`](https://codemirror.net/doc/manual.html#event_dom). [protobuf mode](https://codemirror.net/mode/protobuf/index.html): Newly added. ### Bugfixes Fix problem where [`findMarks`](https://codemirror.net/doc/manual.html#findMarks) sometimes failed to find multi-line marks. Fix crash that showed up when atomic ranges and bidi text were combined. [show-hint addon](https://codemirror.net/demo/complete.html): Completion widgets no longer close when the line indented or dedented. [merge addon](https://codemirror.net/demo/merge.html): Fix bug when merging chunks at the end of the file. [placeholder addon](https://codemirror.net/doc/manual.html#addon_placeholder): No longer gets confused by [`swapDoc`](https://codemirror.net/doc/manual.html#swapDoc). [simplescrollbars addon](https://codemirror.net/doc/manual.html#addon_simplescrollbars): Fix invalid state when deleting at end of document. [clike mode](https://codemirror.net/mode/clike/index.html): No longer gets confused when a comment starts after an operator. [markdown mode](https://codemirror.net/mode/markdown/index.html): Now supports CommonMark-style flexible list indentation. [dylan mode](https://codemirror.net/mode/dylan/index.html): Several improvements and fixes. ## 5.12.0 (2016-02-19) ### New features [Vim bindings](https://codemirror.net/demo/vim.html): Ctrl-Q is now an alias for Ctrl-V. [Vim bindings](https://codemirror.net/demo/vim.html): The Vim API now exposes an `unmap` method to unmap bindings. [active-line addon](https://codemirror.net/demo/activeline.html): This addon can now style the active line's gutter. [FCL mode](https://codemirror.net/mode/fcl/): Newly added. [SQL mode](https://codemirror.net/mode/sql/): Now has a Postgresql dialect. ### Bugfixes Fix [issue](https://github.com/codemirror/CodeMirror/issues/3781) where trying to scroll to a horizontal position outside of the document's width could cause the gutter to be positioned incorrectly. Use absolute, rather than fixed positioning in the context-menu intercept hack, to work around a [problem](https://github.com/codemirror/CodeMirror/issues/3238) when the editor is inside a transformed parent container. Solve a [problem](https://github.com/codemirror/CodeMirror/issues/3821) where the horizontal scrollbar could hide text in Firefox. Fix a [bug](https://github.com/codemirror/CodeMirror/issues/3834) that caused phantom scroll space under the text in some situations. [Sublime Text bindings](https://codemirror.net/demo/sublime.html): Bind delete-line to Shift-Ctrl-K on OS X. [Markdown mode](https://codemirror.net/mode/markdown/): Fix [issue](https://github.com/codemirror/CodeMirror/issues/3787) where the mode would keep state related to fenced code blocks in an unsafe way, leading to occasional corrupted parses. [Markdown mode](https://codemirror.net/mode/markdown/): Ignore backslashes in code fragments. [Markdown mode](https://codemirror.net/mode/markdown/): Use whichever mode is registered as `text/html` to parse HTML. [Clike mode](https://codemirror.net/mode/clike/): Improve indentation of Scala `=>` functions. [Python mode](https://codemirror.net/mode/python/): Improve indentation of bracketed code. [HTMLMixed mode](https://codemirror.net/mode/htmlmixed/): Support multi-line opening tags for sub-languages (`CodeMirror-5.51.0/demo/anywordhint.html 0000664 0000000 0000000 00000005176 13611327467 0020052 0 ustar 00root root 0000000 0000000 Active Line Demo
Styling the current cursor line.
CodeMirror: Any Word Completion Demo CodeMirror-5.51.0/demo/bidi.html 0000664 0000000 0000000 00000011453 13611327467 0016406 0 ustar 00root root 0000000 0000000 Any Word Completion Demo
Press ctrl-space to activate autocompletion. The completion uses the anyword-hint.js module, which simply looks at nearby words in the buffer and completes to those.
CodeMirror: Bi-directional Text Demo CodeMirror-5.51.0/demo/btree.html 0000664 0000000 0000000 00000005601 13611327467 0016576 0 ustar 00root root 0000000 0000000 Bi-directional Text Demo
Demonstration of bi-directional text support. See the related blog post for more background.
CodeMirror: B-Tree visualization CodeMirror-5.51.0/demo/buffers.html 0000664 0000000 0000000 00000006735 13611327467 0017142 0 ustar 00root root 0000000 0000000 B-Tree visualization
CodeMirror: Multiple Buffer & Split View Demo CodeMirror-5.51.0/demo/changemode.html 0000664 0000000 0000000 00000003246 13611327467 0017572 0 ustar 00root root 0000000 0000000 Multiple Buffer & Split View Demo
Select buffer:Select buffer:Demonstration of using linked documents to provide a split view on a document, and using
swapDoc
to use a single editor to display multiple documents.CodeMirror: Mode-Changing Demo CodeMirror-5.51.0/demo/closebrackets.html 0000664 0000000 0000000 00000003150 13611327467 0020316 0 ustar 00root root 0000000 0000000 Mode-Changing Demo
On changes to the content of the above editor, a (crude) script tries to auto-detect the language used, and switches the editor to either JavaScript or Scheme mode based on that.
CodeMirror: Closebrackets Demo CodeMirror-5.51.0/demo/closetag.html 0000664 0000000 0000000 00000002347 13611327467 0017302 0 ustar 00root root 0000000 0000000 Closebrackets Demo
CodeMirror: Close-Tag Demo CodeMirror-5.51.0/demo/complete.html 0000664 0000000 0000000 00000010302 13611327467 0017277 0 ustar 00root root 0000000 0000000 Close-Tag Demo
CodeMirror: Autocomplete Demo CodeMirror-5.51.0/demo/emacs.html 0000664 0000000 0000000 00000004672 13611327467 0016574 0 ustar 00root root 0000000 0000000 Autocomplete Demo
Press ctrl-space to activate autocompletion. Built on top of the
show-hint
andjavascript-hint
addons.CodeMirror: Emacs bindings demo CodeMirror-5.51.0/demo/folding.html 0000664 0000000 0000000 00000013233 13611327467 0017117 0 ustar 00root root 0000000 0000000 Emacs bindings demo
The emacs keybindings are enabled by including keymap/emacs.js and setting the
keyMap
option to"emacs"
. Because CodeMirror's internal API is quite different from Emacs, they are only a loose approximation of actual emacs bindings, though.Also note that a lot of browsers disallow certain keys from being captured. For example, Chrome blocks both Ctrl-W and Ctrl-N, with the result that idiomatic use of Emacs keys will constantly close your tab or open a new window.
CodeMirror: Code Folding Demo CodeMirror-5.51.0/demo/fullscreen.html 0000664 0000000 0000000 00000006607 13611327467 0017646 0 ustar 00root root 0000000 0000000 Code Folding Demo
CodeMirror: Full Screen Editing CodeMirror-5.51.0/demo/hardwrap.html 0000664 0000000 0000000 00000004775 13611327467 0017320 0 ustar 00root root 0000000 0000000 Full Screen Editing
Demonstration of the fullscreen addon. Press F11 when cursor is in the editor to toggle full screen editing. Esc can also be used to exit full screen editing.
CodeMirror: Hard-wrapping Demo CodeMirror-5.51.0/demo/html5complete.html 0000664 0000000 0000000 00000003302 13611327467 0020253 0 ustar 00root root 0000000 0000000 Hard-wrapping Demo
Demonstration of the hardwrap addon. The above editor has its change event hooked up to the
wrapParagraphsInRange
method, so that the paragraphs are reflown as you are typing.CodeMirror: HTML completion demo CodeMirror-5.51.0/demo/indentwrap.html 0000664 0000000 0000000 00000005004 13611327467 0017645 0 ustar 00root root 0000000 0000000 HTML completion demo
Shows the XML completer parameterized with information about the tags in HTML. Press ctrl-space to activate completion.
CodeMirror: Indented wrapped line demo CodeMirror-5.51.0/demo/lint.html 0000664 0000000 0000000 00000007703 13611327467 0016450 0 ustar 00root root 0000000 0000000 Indented wrapped line demo
This page uses a hack on top of the
"renderLine"
event to make wrapped text line up with the base indentation of the line.CodeMirror: Linter Demo CodeMirror-5.51.0/demo/loadmode.html 0000664 0000000 0000000 00000004241 13611327467 0017260 0 ustar 00root root 0000000 0000000 Linter Demo
CodeMirror: Lazy Mode Loading Demo CodeMirror-5.51.0/demo/marker.html 0000664 0000000 0000000 00000002676 13611327467 0016767 0 ustar 00root root 0000000 0000000 Lazy Mode Loading Demo
Current mode: text/plain
Filename, mime, or mode name:
CodeMirror: Breakpoint Demo CodeMirror-5.51.0/demo/markselection.html 0000664 0000000 0000000 00000003505 13611327467 0020336 0 ustar 00root root 0000000 0000000 Breakpoint Demo
Click the line-number gutter to add or remove 'breakpoints'.
CodeMirror: Selection Marking Demo CodeMirror-5.51.0/demo/matchhighlighter.html 0000664 0000000 0000000 00000011327 13611327467 0021012 0 ustar 00root root 0000000 0000000 Selection Marking Demo
Simple addon to easily mark (and style) selected text. Docs.
CodeMirror: Match Highlighter Demo CodeMirror-5.51.0/demo/matchtags.html 0000664 0000000 0000000 00000002517 13611327467 0017453 0 ustar 00root root 0000000 0000000 Match Highlighter Demo
Search and highlight occurences of the selected text.
CodeMirror: Tag Matcher Demo CodeMirror-5.51.0/demo/merge.html 0000664 0000000 0000000 00000010126 13611327467 0016572 0 ustar 00root root 0000000 0000000 Tag Matcher Demo
Put the cursor on or inside a pair of tags to highlight them. Press Ctrl-J to jump to the tag that matches the one under the cursor.
CodeMirror: merge view demo CodeMirror-5.51.0/demo/multiplex.html 0000664 0000000 0000000 00000004145 13611327467 0017522 0 ustar 00root root 0000000 0000000 merge view demo
The
merge
addon provides an interface for displaying and merging diffs, either two-way or three-way. The left (or center) pane is editable, and the differences with the other pane(s) are optionally shown live as you edit it. In the two-way configuration, there are also options to pad changed sections to align them, and to collapse unchanged stretches of text.This addon depends on the google-diff-match-patch library to compute the diffs.
CodeMirror: Multiplexing Parser Demo CodeMirror-5.51.0/demo/mustache.html 0000664 0000000 0000000 00000004041 13611327467 0017303 0 ustar 00root root 0000000 0000000 Multiplexing Parser Demo
Demonstration of a multiplexing mode, which, at certain boundary strings, switches to one or more inner modes. The out (HTML) mode does not get fed the content of the
<< >>
blocks. See the manual and the source for more information.CodeMirror: Overlay Parser Demo CodeMirror-5.51.0/demo/panel.html 0000664 0000000 0000000 00000006616 13611327467 0016603 0 ustar 00root root 0000000 0000000 Overlay Parser Demo
Demonstration of a mode that parses HTML, highlighting the Mustache templating directives inside of it by using the code in
overlay.js
. View source to see the 15 lines of code needed to accomplish this.CodeMirror: Panel Demo CodeMirror-5.51.0/demo/placeholder.html 0000664 0000000 0000000 00000002724 13611327467 0017762 0 ustar 00root root 0000000 0000000 Panel Demo
The
panel
addon allows you to display panels above or below an editor.
Click the links below to add panels at the given position:top after-top before-bottom bottom
You can also replace an existing panel:
CodeMirror: Placeholder demo CodeMirror-5.51.0/demo/preview.html 0000664 0000000 0000000 00000004562 13611327467 0017163 0 ustar 00root root 0000000 0000000 Placeholder demo
The placeholder plug-in adds an option
placeholder
that can be set to make text appear in the editor when it is empty and not focused. If the source textarea has aplaceholder
attribute, it will automatically be inherited.CodeMirror: HTML5 preview CodeMirror-5.51.0/demo/requirejs.html 0000664 0000000 0000000 00000004354 13611327467 0017512 0 ustar 00root root 0000000 0000000 HTML5 preview
CodeMirror: HTML completion demo CodeMirror-5.51.0/demo/resize.html 0000664 0000000 0000000 00000002477 13611327467 0017006 0 ustar 00root root 0000000 0000000 RequireJS module loading demo
This demo does the same thing as the HTML5 completion demo, but loads its dependencies with Require.js, rather than explicitly. Press ctrl-space to activate completion.
CodeMirror: Autoresize Demo CodeMirror-5.51.0/demo/rulers.html 0000664 0000000 0000000 00000002555 13611327467 0017016 0 ustar 00root root 0000000 0000000 Autoresize Demo
By setting an editor's
height
style toauto
and giving theviewportMargin
a value ofInfinity
, CodeMirror can be made to automatically resize to fit its content.CodeMirror: Ruler Demo CodeMirror-5.51.0/demo/runmode.html 0000664 0000000 0000000 00000004332 13611327467 0017146 0 ustar 00root root 0000000 0000000 Ruler Demo
Demonstration of the rulers addon, which displays vertical lines at given column offsets.
CodeMirror: Mode Runner Demo CodeMirror-5.51.0/demo/search.html 0000664 0000000 0000000 00000010657 13611327467 0016751 0 ustar 00root root 0000000 0000000 Mode Runner Demo
Running a CodeMirror mode outside of the editor. The
CodeMirror.runMode
function, defined inaddon/runmode/runmode.js
takes the following arguments:
text (string)
- The document to run through the highlighter.
mode (mode spec)
- The mode to use (must be loaded as normal).
output (function or DOM node)
- If this is a function, it will be called for each token with two arguments, the token's text and the token's style class (may be
null
for unstyled tokens). If it is a DOM node, the tokens will be converted tospan
elements as in an editor, and inserted into the node (throughinnerHTML
).CodeMirror: Search/Replace Demo CodeMirror-5.51.0/demo/simplemode.html 0000664 0000000 0000000 00000017613 13611327467 0017641 0 ustar 00root root 0000000 0000000 Search/Replace Demo
Demonstration of primitive search/replace functionality. The keybindings (which can be configured with custom keymaps) are:
- Ctrl-F / Cmd-F
- Start searching
- Ctrl-G / Cmd-G
- Find next
- Shift-Ctrl-G / Shift-Cmd-G
- Find previous
- Shift-Ctrl-F / Cmd-Option-F
- Replace
- Shift-Ctrl-R / Shift-Cmd-Option-F
- Replace all
- Alt-F
- Persistent search (dialog doesn't autoclose, enter to find next, Shift-Enter to find previous)
- Alt-G
- Jump to line
Searching is enabled by including addon/search/search.js and addon/search/searchcursor.js. Jump to line - including addon/search/jump-to-line.js.
For good-looking input dialogs, you also want to include addon/dialog/dialog.js and addon/dialog/dialog.css.
CodeMirror: Simple Mode Demo CodeMirror-5.51.0/demo/simplescrollbars.html 0000664 0000000 0000000 00000011624 13611327467 0021057 0 ustar 00root root 0000000 0000000 Simple Mode Demo
The
mode/simple
addon allows CodeMirror modes to be specified using a relatively simple declarative format. This format is not as powerful as writing code directly against the mode interface, but is a lot easier to get started with, and sufficiently expressive for many simple language modes.This interface is still in flux. It is unlikely to be scrapped or overhauled completely, so do start writing code against it, but details might change as it stabilizes, and you might have to tweak your code when upgrading.
Simple modes (loosely based on the Common JavaScript Syntax Highlighting Specification, which never took off), are state machines, where each state has a number of rules that match tokens. A rule describes a type of token that may occur in the current state, and possibly a transition to another state caused by that token.
The
CodeMirror.defineSimpleMode(name, states)
method takes a mode name and an object that describes the mode's states. The editor below shows an example of such a mode (and is itself highlighted by the mode shown in it).Each state is an array of rules. A rule may have the following properties:
regex: string | RegExp
- The regular expression that matches the token. May be a string or a regex object. When a regex, the
ignoreCase
flag will be taken into account when matching the token. This regex has to capture groups when thetoken
property is an array. If it captures groups, it must capture all of the string (since JS provides no way to find out where a group matched).token
: string | array<string> | null- An optional token style. Multiple styles can be specified by separating them with dots or spaces. When this property holds an array of token styles, the
regex
for this rule must capture a group for each array item.sol
: boolean- When true, this token will only match at the start of the line. (The
^
regexp marker doesn't work as you'd expect in this context because of limitations in JavaScript's RegExp API.)next: string
- When a
next
property is present, the mode will transfer to the state named by the property when the token is encountered.push: string
- Like
next
, but instead replacing the current state by the new state, the current state is kept on a stack, and can be returned to with thepop
directive.pop: bool
- When true, and there is another state on the state stack, will cause the mode to pop that state off the stack and transition to it.
mode: {spec, end, persistent}
- Can be used to embed another mode inside a mode. When present, must hold an object with a
spec
property that describes the embedded mode, and an optionalend
end property that specifies the regexp that will end the extent of the mode. When apersistent
property is set (and true), the nested mode's state will be preserved between occurrences of the mode.indent: bool
- When true, this token changes the indentation to be one unit more than the current line's indentation.
dedent: bool
- When true, this token will pop one scope off the indentation stack.
dedentIfLineStart: bool
- If a token has its
dedent
property set, it will, by default, cause lines where it appears at the start to be dedented. Set this property to false to prevent that behavior.The
meta
property of the states object is special, and will not be interpreted as a state. Instead, properties set on it will be set on the mode, which is useful for properties likelineComment
, which sets the comment style for a mode. The simple mode addon also recognizes a few such properties:
dontIndentStates: array<string>
- An array of states in which the mode's auto-indentation should not take effect. Usually used for multi-line comment and string states.
CodeMirror: Simple Scrollbar Demo CodeMirror-5.51.0/demo/spanaffectswrapping_shim.html 0000664 0000000 0000000 00000005740 13611327467 0022566 0 ustar 00root root 0000000 0000000 Simple Scrollbar Demo
The
simplescrollbars
addon defines two styles of non-native scrollbars:"simple"
and"overlay"
(click to try), which can be passed to thescrollbarStyle
option. These implement the scrollbar using DOM elements, allowing more control over its appearance.CodeMirror: Automatically derive odd wrapping behavior for your browser CodeMirror-5.51.0/demo/sublime.html 0000664 0000000 0000000 00000005413 13611327467 0017136 0 ustar 00root root 0000000 0000000 Automatically derive odd wrapping behavior for your browser
This is a hack to automatically derive a
spanAffectsWrapping
regexp for a browser. See the comments above that variable inlib/codemirror.js
for some more details.CodeMirror: Sublime Text bindings demo CodeMirror-5.51.0/demo/tern.html 0000664 0000000 0000000 00000010605 13611327467 0016445 0 ustar 00root root 0000000 0000000 Sublime Text bindings demo
The
sublime
keymap defines many Sublime Text-specific bindings for CodeMirror. See the code below for an overview.Enable the keymap by loading
keymap/sublime.js
and setting thekeyMap
option to"sublime"
.(A lot of the search functionality is still missing.)
CodeMirror: Tern Demo CodeMirror-5.51.0/demo/theme.html 0000664 0000000 0000000 00000016311 13611327467 0016577 0 ustar 00root root 0000000 0000000 Tern Demo
Demonstrates integration of Tern and CodeMirror. The following keys are bound:
- Ctrl-Space
- Autocomplete
- Ctrl-O
- Find docs for the expression at the cursor
- Ctrl-I
- Find type at cursor
- Alt-.
- Jump to definition (Alt-, to jump back)
- Ctrl-Q
- Rename variable
- Ctrl-.
- Select all occurrences of a variable
Documentation is sparse for now. See the top of the script for a rough API overview.
CodeMirror: Theme Demo CodeMirror-5.51.0/demo/trailingspace.html 0000664 0000000 0000000 00000003020 13611327467 0020313 0 ustar 00root root 0000000 0000000 Theme Demo
Select a theme:
CodeMirror: Trailing Whitespace Demo CodeMirror-5.51.0/demo/variableheight.html 0000664 0000000 0000000 00000004004 13611327467 0020447 0 ustar 00root root 0000000 0000000 Trailing Whitespace Demo
Uses the trailingspace addon to highlight trailing whitespace.
CodeMirror: Variable Height Demo CodeMirror-5.51.0/demo/vim.html 0000664 0000000 0000000 00000007632 13611327467 0016276 0 ustar 00root root 0000000 0000000 Variable Height Demo
CodeMirror: Vim bindings demo CodeMirror-5.51.0/demo/visibletabs.html 0000664 0000000 0000000 00000003467 13611327467 0020014 0 ustar 00root root 0000000 0000000 Vim bindings demo
Note: The CodeMirror vim bindings do not have an active maintainer. That means that if you report bugs in it, they are likely to go unanswered. It also means that if you want to help, you are very welcome to look at the open issues and see which ones you can solve.
Key buffer:The vim keybindings are enabled by including
keymap/vim.js
and setting thekeyMap
option tovim
.Features
- All common motions and operators, including text objects
- Operator motion orthogonality
- Visual mode - characterwise, linewise, blockwise
- Full macro support (q, @)
- Incremental highlighted search (/, ?, #, *, g#, g*)
- Search/replace with confirm (:substitute, :%s)
- Search history
- Jump lists (Ctrl-o, Ctrl-i)
- Key/command mapping with API (:map, :nmap, :vmap)
- Sort (:sort)
- Marks (`, ')
- :global
- Insert mode behaves identical to base CodeMirror
- Cross-buffer yank/paste
For the full list of key mappings and Ex commands, refer to the
defaultKeymap
anddefaultExCommandMap
at the top ofkeymap/vim.js
.Note that while the vim mode tries to emulate the most useful features of vim as faithfully as possible, it does not strive to become a complete vim implementation
CodeMirror: Visible tabs demo CodeMirror-5.51.0/demo/widget.html 0000664 0000000 0000000 00000005576 13611327467 0016773 0 ustar 00root root 0000000 0000000 Visible tabs demo
Tabs inside the editor are spans with the class
cm-tab
, and can be styled.CodeMirror: Inline Widget Demo CodeMirror-5.51.0/demo/xmlcomplete.html 0000664 0000000 0000000 00000007150 13611327467 0020027 0 ustar 00root root 0000000 0000000 Inline Widget Demo
This demo runs JSHint over the code in the editor (which is the script used on this page), and inserts line widgets to display the warnings that JSHint comes up with.
CodeMirror: XML Autocomplete Demo CodeMirror-5.51.0/doc/ 0000775 0000000 0000000 00000000000 13611327467 0014426 5 ustar 00root root 0000000 0000000 CodeMirror-5.51.0/doc/activebookmark.js 0000664 0000000 0000000 00000003551 13611327467 0017771 0 ustar 00root root 0000000 0000000 // Kludge in HTML5 tag recognition in IE8 document.createElement("section"); document.createElement("article"); (function() { if (!window.addEventListener) return; var pending = false, prevVal = null; function updateSoon() { if (!pending) { pending = true; setTimeout(update, 250); } } function update() { pending = false; var marks = document.getElementById("nav").getElementsByTagName("a"), found; for (var i = 0; i < marks.length; ++i) { var mark = marks[i], m; if (mark.getAttribute("data-default")) { if (found == null) found = i; } else if (m = mark.href.match(/#(.*)/)) { var ref = document.getElementById(m[1]); if (ref && ref.getBoundingClientRect().top < 50) found = i; } } if (found != null && found != prevVal) { prevVal = found; var lis = document.getElementById("nav").getElementsByTagName("li"); for (var i = 0; i < lis.length; ++i) lis[i].className = ""; for (var i = 0; i < marks.length; ++i) { if (found == i) { marks[i].className = "active"; for (var n = marks[i]; n; n = n.parentNode) if (n.nodeName == "LI") n.className = "active"; } else { marks[i].className = ""; } } } } window.addEventListener("scroll", updateSoon); window.addEventListener("load", updateSoon); window.addEventListener("hashchange", function() { setTimeout(function() { var hash = document.location.hash, found = null, m; var marks = document.getElementById("nav").getElementsByTagName("a"); for (var i = 0; i < marks.length; i++) if ((m = marks[i].href.match(/(#.*)/)) && m[1] == hash) { found = i; break; } if (found != null) for (var i = 0; i < marks.length; i++) marks[i].className = i == found ? "active" : ""; }, 300); }); })(); CodeMirror-5.51.0/doc/docs.css 0000664 0000000 0000000 00000010023 13611327467 0016064 0 ustar 00root root 0000000 0000000 @font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 400; src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url(//themes.googleusercontent.com/static/fonts/sourcesanspro/v5/ODelI1aHBYDBqgeIAH2zlBM0YzuT7MdOe03otPbuUS0.woff) format('woff'); } body, html { margin: 0; padding: 0; height: 100%; } section, article { display: block; padding: 0; } body { background: #f8f8f8; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; line-height: 1.5; } p { margin-top: 0; } h2, h3, h1 { font-weight: normal; margin-bottom: .7em; } h1 { font-size: 140%; } h2 { font-size: 120%; } h3 { font-size: 110%; } article > h2:first-child, section:first-child > h2 { margin-top: 0; } #nav h1 { margin-right: 12px; margin-top: 0; margin-bottom: 2px; color: #d30707; letter-spacing: .5px; } a, a:visited, a:link, .quasilink { color: #A21313; } em { padding-right: 2px; } .quasilink { cursor: pointer; } article { max-width: 700px; margin: 0 0 0 160px; border-left: 2px solid #E30808; border-right: 1px solid #ddd; padding: 30px 50px 100px 50px; background: white; z-index: 2; position: relative; min-height: 100%; box-sizing: border-box; -moz-box-sizing: border-box; } #nav { position: fixed; padding-top: 30px; max-height: 100%; box-sizing: -moz-border-box; box-sizing: border-box; overflow-y: auto; left: 0; right: none; width: 160px; text-align: right; z-index: 1; } @media screen and (min-width: 1000px) { article { margin: 0 auto; } #nav { right: 50%; width: auto; border-right: 349px solid transparent; } } #nav ul { display: block; margin: 0; padding: 0; margin-bottom: 32px; } #nav a { text-decoration: none; } #nav li { display: block; margin-bottom: 4px; } #nav li ul { font-size: 80%; margin-bottom: 0; display: none; } #nav li.active ul { display: block; } #nav li li a { padding-right: 20px; display: inline-block; } #nav ul a { color: black; padding: 0 7px 1px 11px; } #nav ul a.active, #nav ul a:hover { border-bottom: 1px solid #E30808; margin-bottom: -1px; color: #E30808; } #logo { border: 0; margin-right: 12px; margin-bottom: 25px; } section { border-top: 1px solid #E30808; margin: 1.5em 0; } section.first { border: none; margin-top: 0; } #demo { position: relative; } #demolist { position: absolute; right: 5px; top: 5px; z-index: 25; } .yinyang { position: absolute; top: -10px; left: 0; right: 0; margin: auto; display: block; height: 120px; } .actions { margin: 1em 0 0; min-height: 100px; position: relative; } .actionspicture { pointer-events: none; position: absolute; height: 100px; top: 0; left: 0; right: 0; } .actionlink { pointer-events: auto; font-family: arial; font-size: 80%; font-weight: bold; position: absolute; top: 0; bottom: 0; line-height: 1; height: 1em; margin: auto; } .actionlink.download { color: white; right: 50%; margin-right: 13px; text-shadow: -1px 1px 3px #b00, -1px -1px 3px #b00, 1px 0px 3px #b00; } .actionlink.fund { color: #b00; left: 50%; margin-left: 15px; } .actionlink:hover { text-decoration: underline; } .actionlink a { color: inherit; } .actionsleft { float: left; } .actionsright { float: right; text-align: right; } @media screen and (max-width: 800px) { .actions { padding-top: 120px; } .actionsleft, .actionsright { float: none; text-align: left; margin-bottom: 1em; } } th { text-decoration: underline; font-weight: normal; text-align: left; } #features ul { list-style: none; margin: 0 0 1em; padding: 0 0 0 1.2em; } #features li:before { content: "-"; width: 1em; display: inline-block; padding: 0; margin: 0; margin-left: -1em; } .rel { margin-bottom: 0; } .rel-note { margin-top: 0; color: #555; } pre { padding-left: 15px; border-left: 2px solid #ddd; } code { padding: 0 2px; } strong { text-decoration: underline; font-weight: normal; } .field { border: 1px solid #A21313; } CodeMirror-5.51.0/doc/internals.html 0000664 0000000 0000000 00000062236 13611327467 0017324 0 ustar 00root root 0000000 0000000 XML Autocomplete Demo
Press ctrl-space, or type a '<' character to activate autocompletion. This demo defines a simple schema that guides completion. The schema can be customized—see the manual.
Development of the
xml-hint
addon was kindly sponsored by www.xperiment.mobi.CodeMirror: Internals CodeMirror-5.51.0/doc/logo.png 0000664 0000000 0000000 00000022136 13611327467 0016100 0 ustar 00root root 0000000 0000000 PNG IHDR q i & (Re-) Implementing A Syntax-Highlighting Editor in JavaScript
Topic: JavaScript, code editor implementation
Author: Marijn Haverbeke
Date: March 2nd 2011 (updated November 13th 2011)Caution: this text was written briefly after version 2 was initially written. It no longer (even including the update at the bottom) fully represents the current implementation. I'm leaving it here as a historic document. For more up-to-date information, look at the entries tagged cm-internals on my blog.
This is a followup to my Brutal Odyssey to the Dark Side of the DOM Tree story. That one describes the mind-bending process of implementing (what would become) CodeMirror 1. This one describes the internals of CodeMirror 2, a complete rewrite and rethink of the old code base. I wanted to give this piece another Hunter Thompson copycat subtitle, but somehow that would be out of place—the process this time around was one of straightforward engineering, requiring no serious mind-bending whatsoever.
So, what is wrong with CodeMirror 1? I'd estimate, by mailing list activity and general search-engine presence, that it has been integrated into about a thousand systems by now. The most prominent one, since a few weeks, being Google code's project hosting. It works, and it's being used widely.
Still, I did not start replacing it because I was bored. CodeMirror 1 was heavily reliant on
designMode
orcontentEditable
(depending on the browser). Neither of these are well specified (HTML5 tries to specify their basics), and, more importantly, they tend to be one of the more obscure and buggy areas of browser functionality—CodeMirror, by using this functionality in a non-typical way, was constantly running up against browser bugs. WebKit wouldn't show an empty line at the end of the document, and in some releases would suddenly get unbearably slow. Firefox would show the cursor in the wrong place. Internet Explorer would insist on linkifying everything that looked like a URL or email address, a behaviour that can't be turned off. Some bugs I managed to work around (which was often a frustrating, painful process), others, such as the Firefox cursor placement, I gave up on, and had to tell user after user that they were known problems, but not something I could help.Also, there is the fact that
designMode
(which seemed to be less buggy thancontentEditable
in Webkit and Firefox, and was thus used by CodeMirror 1 in those browsers) requires a frame. Frames are another tricky area. It takes some effort to prevent getting tripped up by domain restrictions, they don't initialize synchronously, behave strangely in response to the back button, and, on several browsers, can't be moved around the DOM without having them re-initialize. They did provide a very nice way to namespace the library, though—CodeMirror 1 could freely pollute the namespace inside the frame.Finally, working with an editable document means working with selection in arbitrary DOM structures. Internet Explorer (8 and before) has an utterly different (and awkward) selection API than all of the other browsers, and even among the different implementations of
document.selection
, details about how exactly a selection is represented vary quite a bit. Add to that the fact that Opera's selection support tended to be very buggy until recently, and you can imagine why CodeMirror 1 contains 700 lines of selection-handling code.And that brings us to the main issue with the CodeMirror 1 code base: The proportion of browser-bug-workarounds to real application code was getting dangerously high. By building on top of a few dodgy features, I put the system in a vulnerable position—any incompatibility and bugginess in these features, I had to paper over with my own code. Not only did I have to do some serious stunt-work to get it to work on older browsers (as detailed in the previous story), things also kept breaking in newly released versions, requiring me to come up with new scary hacks in order to keep up. This was starting to lose its appeal.
General Approach
What CodeMirror 2 does is try to sidestep most of the hairy hacks that came up in version 1. I owe a lot to the ACE editor for inspiration on how to approach this.
I absolutely did not want to be completely reliant on key events to generate my input. Every JavaScript programmer knows that key event information is horrible and incomplete. Some people (most awesomely Mihai Bazon with Ymacs) have been able to build more or less functioning editors by directly reading key events, but it takes a lot of work (the kind of never-ending, fragile work I described earlier), and will never be able to properly support things like multi-keystoke international character input. [see below for caveat]
So what I do is focus a hidden textarea, and let the browser believe that the user is typing into that. What we show to the user is a DOM structure we built to represent his document. If this is updated quickly enough, and shows some kind of believable cursor, it feels like a real text-input control.
Another big win is that this DOM representation does not have to span the whole document. Some CodeMirror 1 users insisted that they needed to put a 30 thousand line XML document into CodeMirror. Putting all that into the DOM takes a while, especially since, for some reason, an editable DOM tree is slower than a normal one on most browsers. If we have full control over what we show, we must only ensure that the visible part of the document has been added, and can do the rest only when needed. (Fortunately, the
onscroll
event works almost the same on all browsers, and lends itself well to displaying things only as they are scrolled into view.)Input
ACE uses its hidden textarea only as a text input shim, and does all cursor movement and things like text deletion itself by directly handling key events. CodeMirror's way is to let the browser do its thing as much as possible, and not, for example, define its own set of key bindings. One way to do this would have been to have the whole document inside the hidden textarea, and after each key event update the display DOM to reflect what's in that textarea.
That'd be simple, but it is not realistic. For even medium-sized document the editor would be constantly munging huge strings, and get terribly slow. What CodeMirror 2 does is put the current selection, along with an extra line on the top and on the bottom, into the textarea.
This means that the arrow keys (and their ctrl-variations), home, end, etcetera, do not have to be handled specially. We just read the cursor position in the textarea, and update our cursor to match it. Also, copy and paste work pretty much for free, and people get their native key bindings, without any special work on my part. For example, I have emacs key bindings configured for Chrome and Firefox. There is no way for a script to detect this. [no longer the case]
Of course, since only a small part of the document sits in the textarea, keys like page up and ctrl-end won't do the right thing. CodeMirror is catching those events and handling them itself.
Selection
Getting and setting the selection range of a textarea in modern browsers is trivial—you just use the
selectionStart
andselectionEnd
properties. On IE you have to do some insane stuff with temporary ranges and compensating for the fact that moving the selection by a 'character' will treat \r\n as a single character, but even there it is possible to build functions that reliably set and get the selection range.But consider this typical case: When I'm somewhere in my document, press shift, and press the up arrow, something gets selected. Then, if I, still holding shift, press the up arrow again, the top of my selection is adjusted. The selection remembers where its head and its anchor are, and moves the head when we shift-move. This is a generally accepted property of selections, and done right by every editing component built in the past twenty years.
But not something that the browser selection APIs expose.
Great. So when someone creates an 'upside-down' selection, the next time CodeMirror has to update the textarea, it'll re-create the selection as an 'upside-up' selection, with the anchor at the top, and the next cursor motion will behave in an unexpected way—our second up-arrow press in the example above will not do anything, since it is interpreted in exactly the same way as the first.
No problem. We'll just, ehm, detect that the selection is upside-down (you can tell by the way it was created), and then, when an upside-down selection is present, and a cursor-moving key is pressed in combination with shift, we quickly collapse the selection in the textarea to its start, allow the key to take effect, and then combine its new head with its old anchor to get the real selection.
In short, scary hacks could not be avoided entirely in CodeMirror 2.
And, the observant reader might ask, how do you even know that a key combo is a cursor-moving combo, if you claim you support any native key bindings? Well, we don't, but we can learn. The editor keeps a set known cursor-movement combos (initialized to the predictable defaults), and updates this set when it observes that pressing a certain key had (only) the effect of moving the cursor. This, of course, doesn't work if the first time the key is used was for extending an inverted selection, but it works most of the time.
Intelligent Updating
One thing that always comes up when you have a complicated internal state that's reflected in some user-visible external representation (in this case, the displayed code and the textarea's content) is keeping the two in sync. The naive way is to just update the display every time you change your state, but this is not only error prone (you'll forget), it also easily leads to duplicate work on big, composite operations. Then you start passing around flags indicating whether the display should be updated in an attempt to be efficient again and, well, at that point you might as well give up completely.
I did go down that road, but then switched to a much simpler model: simply keep track of all the things that have been changed during an action, and then, only at the end, use this information to update the user-visible display.
CodeMirror uses a concept of operations, which start by calling a specific set-up function that clears the state and end by calling another function that reads this state and does the required updating. Most event handlers, and all the user-visible methods that change state are wrapped like this. There's a method called
operation
that accepts a function, and returns another function that wraps the given function as an operation.It's trivial to extend this (as CodeMirror does) to detect nesting, and, when an operation is started inside an operation, simply increment the nesting count, and only do the updating when this count reaches zero again.
If we have a set of changed ranges and know the currently shown range, we can (with some awkward code to deal with the fact that changes can add and remove lines, so we're dealing with a changing coordinate system) construct a map of the ranges that were left intact. We can then compare this map with the part of the document that's currently visible (based on scroll offset and editor height) to determine whether something needs to be updated.
CodeMirror uses two update algorithms—a full refresh, where it just discards the whole part of the DOM that contains the edited text and rebuilds it, and a patch algorithm, where it uses the information about changed and intact ranges to update only the out-of-date parts of the DOM. When more than 30 percent (which is the current heuristic, might change) of the lines need to be updated, the full refresh is chosen (since it's faster to do than painstakingly finding and updating all the changed lines), in the other case it does the patching (so that, if you scroll a line or select another character, the whole screen doesn't have to be re-rendered). [the full-refresh algorithm was dropped, it wasn't really faster than the patching one]
All updating uses
innerHTML
rather than direct DOM manipulation, since that still seems to be by far the fastest way to build documents. There's a per-line function that combines the highlighting, marking, and selection info for that line into a snippet of HTML. The patch updater uses this to reset individual lines, the refresh updater builds an HTML chunk for the whole visible document at once, and then uses a singleinnerHTML
update to do the refresh.Parsers can be Simple
When I wrote CodeMirror 1, I thought interruptable parsers were a hugely scary and complicated thing, and I used a bunch of heavyweight abstractions to keep this supposed complexity under control: parsers were iterators that consumed input from another iterator, and used funny closure-resetting tricks to copy and resume themselves.
This made for a rather nice system, in that parsers formed strictly separate modules, and could be composed in predictable ways. Unfortunately, it was quite slow (stacking three or four iterators on top of each other), and extremely intimidating to people not used to a functional programming style.
With a few small changes, however, we can keep all those advantages, but simplify the API and make the whole thing less indirect and inefficient. CodeMirror 2's mode API uses explicit state objects, and makes the parser/tokenizer a function that simply takes a state and a character stream abstraction, advances the stream one token, and returns the way the token should be styled. This state may be copied, optionally in a mode-defined way, in order to be able to continue a parse at a given point. Even someone who's never touched a lambda in his life can understand this approach. Additionally, far fewer objects are allocated in the course of parsing now.
The biggest speedup comes from the fact that the parsing no longer has to touch the DOM though. In CodeMirror 1, on an older browser, you could see the parser work its way through the document, managing some twenty lines in each 50-millisecond time slice it got. It was reading its input from the DOM, and updating the DOM as it went along, which any experienced JavaScript programmer will immediately spot as a recipe for slowness. In CodeMirror 2, the parser usually finishes the whole document in a single 100-millisecond time slice—it manages some 1500 lines during that time on Chrome. All it has to do is munge strings, so there is no real reason for it to be slow anymore.
What Gives?
Given all this, what can you expect from CodeMirror 2?
- Small. the base library is some 45k when minified now, 17k when gzipped. It's smaller than its own logo.
- Lightweight. CodeMirror 2 initializes very quickly, and does almost no work when it is not focused. This means you can treat it almost like a textarea, have multiple instances on a page without trouble.
- Huge document support. Since highlighting is really fast, and no DOM structure is being built for non-visible content, you don't have to worry about locking up your browser when a user enters a megabyte-sized document.
- Extended API. Some things kept coming up in the mailing list, such as marking pieces of text or lines, which were extremely hard to do with CodeMirror 1. The new version has proper support for these built in.
- Tab support. Tabs inside editable documents were, for some reason, a no-go. At least six different people announced they were going to add tab support to CodeMirror 1, none survived (I mean, none delivered a working version). CodeMirror 2 no longer removes tabs from your document.
- Sane styling.
iframe
nodes aren't really known for respecting document flow. Now that an editor instance is a plaindiv
element, it is much easier to size it to fit the surrounding elements. You don't even have to make it scroll if you do not want to.On the downside, a CodeMirror 2 instance is not a native editable component. Though it does its best to emulate such a component as much as possible, there is functionality that browsers just do not allow us to hook into. Doing select-all from the context menu, for example, is not currently detected by CodeMirror.
[Updates from November 13th 2011] Recently, I've made some changes to the codebase that cause some of the text above to no longer be current. I've left the text intact, but added markers at the passages that are now inaccurate. The new situation is described below.
Content Representation
The original implementation of CodeMirror 2 represented the document as a flat array of line objects. This worked well—splicing arrays will require the part of the array after the splice to be moved, but this is basically just a simple
memmove
of a bunch of pointers, so it is cheap even for huge documents.However, I recently added line wrapping and code folding (line collapsing, basically). Once lines start taking up a non-constant amount of vertical space, looking up a line by vertical position (which is needed when someone clicks the document, and to determine the visible part of the document during scrolling) can only be done with a linear scan through the whole array, summing up line heights as you go. Seeing how I've been going out of my way to make big documents fast, this is not acceptable.
The new representation is based on a B-tree. The leaves of the tree contain arrays of line objects, with a fixed minimum and maximum size, and the non-leaf nodes simply hold arrays of child nodes. Each node stores both the amount of lines that live below them and the vertical space taken up by these lines. This allows the tree to be indexed both by line number and by vertical position, and all access has logarithmic complexity in relation to the document size.
I gave line objects and tree nodes parent pointers, to the node above them. When a line has to update its height, it can simply walk these pointers to the top of the tree, adding or subtracting the difference in height from each node it encounters. The parent pointers also make it cheaper (in complexity terms, the difference is probably tiny in normal-sized documents) to find the current line number when given a line object. In the old approach, the whole document array had to be searched. Now, we can just walk up the tree and count the sizes of the nodes coming before us at each level.
I chose B-trees, not regular binary trees, mostly because they allow for very fast bulk insertions and deletions. When there is a big change to a document, it typically involves adding, deleting, or replacing a chunk of subsequent lines. In a regular balanced tree, all these inserts or deletes would have to be done separately, which could be really expensive. In a B-tree, to insert a chunk, you just walk down the tree once to find where it should go, insert them all in one shot, and then break up the node if needed. This breaking up might involve breaking up nodes further up, but only requires a single pass back up the tree. For deletion, I'm somewhat lax in keeping things balanced—I just collapse nodes into a leaf when their child count goes below a given number. This means that there are some weird editing patterns that may result in a seriously unbalanced tree, but even such an unbalanced tree will perform well, unless you spend a day making strangely repeating edits to a really big document.
Keymaps
Above, I claimed that directly catching key events for things like cursor movement is impractical because it requires some browser-specific kludges. I then proceeded to explain some awful hacks that were needed to make it possible for the selection changes to be detected through the textarea. In fact, the second hack is about as bad as the first.
On top of that, in the presence of user-configurable tab sizes and collapsed and wrapped lines, lining up cursor movement in the textarea with what's visible on the screen becomes a nightmare. Thus, I've decided to move to a model where the textarea's selection is no longer depended on.
So I moved to a model where all cursor movement is handled by my own code. This adds support for a goal column, proper interaction of cursor movement with collapsed lines, and makes it possible for vertical movement to move through wrapped lines properly, instead of just treating them like non-wrapped lines.
The key event handlers now translate the key event into a string, something like
Ctrl-Home
orShift-Cmd-R
, and use that string to look up an action to perform. To make keybinding customizable, this lookup goes through a table, using a scheme that allows such tables to be chained together (for example, the default Mac bindings fall through to a table named 'emacsy', which defines basic Emacs-style bindings likeCtrl-F
, and which is also used by the custom Emacs bindings).A new option
extraKeys
allows ad-hoc keybindings to be defined in a much nicer way than what was possible with the oldonKeyEvent
callback. You simply provide an object mapping key identifiers to functions, instead of painstakingly looking at raw key events.Built-in commands map to strings, rather than functions, for example
"goLineUp"
is the default action bound to the up arrow key. This allows new keymaps to refer to them without duplicating any code. New commands can be defined by assigning to theCodeMirror.commands
object, which maps such commands to functions.The hidden textarea now only holds the current selection, with no extra characters around it. This has a nice advantage: polling for input becomes much, much faster. If there's a big selection, this text does not have to be read from the textarea every time—when we poll, just noticing that something is still selected is enough to tell us that no new text was typed.
The reason that cheap polling is important is that many browsers do not fire useful events on IME (input method engine) input, which is the thing where people inputting a language like Japanese or Chinese use multiple keystrokes to create a character or sequence of characters. Most modern browsers fire
input
when the composing is finished, but many don't fire anything when the character is updated during composition. So we poll, whenever the editor is focused, to provide immediate updates of the display.