Skip to content

Releases: FIameCaster/prism-code-editor

Release 3.3.2

12 Jun 21:47
Compare
Choose a tag to compare
  • Switched from line commends to end of line comments for comment toggling in Abap (1c9648f)
  • Added some missing tokens to the GitHub Dark Dimmed and Night Owl themes (bbb559c)
  • Improved behavior when deleting spaces used for indentation (9709e75)
  • Fixed some commands scrolling the cursor into view in read-only mode (9709e75)
  • Improved cursor position extension on wrapping lines (f15b524)
  • Selection matches and the search widget are no longer hidden with display: none, instead being removed from the DOM (b0ea8cd)
  • The web components are now form-friendly thanks to @wyrmisis (#20)

Release 3.3.1

02 May 16:41
Compare
Choose a tag to compare
  • Added auto-indenting and comment toggling to the aliases of bash and xeora (550c39f)
  • Added support for tag matching in actionscript (7d8b049)
  • Fixed issue with the string pattern in typoscript (770e9bb)
  • Fixed the automatic closing of directive blocks in apacheconf (616b7f7)
  • Fixed automatic indentation and tag-closing in XML (ab15799)
  • Fixed the automatic tag closing affecting prologs (ab15799)
  • All attributes starting with on are now highlighted as JavaScript instead of just a few in markup (c333b81)
  • editor.options.value is no longer synchronized with editor.value when calling editor.setOptions() (a5b53b1)
  • Small improvements to multiple themes (5132cd3)

Release 3.3.0

18 Apr 16:51
Compare
Choose a tag to compare
  • Added comment toggling to the following languages: abap, agda, basic, batch, bbj, excel-formula, vbnet, yang and zig (3757059)
  • Fixed prism-code-editor/languages/bsl overriding comment toggling for bro instead of adding comment toggling to bsl (3757059)
  • Fixed incorrect tokens used for comment toggling in cshtml (3757059)
  • Added some language- aliases to the HTTP language (8818315)
  • Fixed line comments not being highlighted at the start of the first line in soy (276ca3a)
  • Small changes to the stylus language so it works better with bracket matching (c77f262)
  • Square- and round brackets are no longer converted to plain text in JSX contexts allowing them to be matched together (2cfc21d)
  • Small performance improvement for when only a single line changes (9289101)

Release 3.2.1

05 Apr 00:51
Compare
Choose a tag to compare

Search widget improvements

  • Fixed issue replacing adjacent matches there the previous match was selected instead (05a941d)
  • Fixed selection matches being highlighted after replacing using the keyboard shortcuts (05a941d)
  • Fixed issue where replacing empty matches with an empty string would delete a character (05a941d)
  • Fixed the textarea stealing focus from the find input in Safari (7645cee)
  • When the replace button selected the closest match, it was scrolled into view without scroll padding. Scroll padding is now used (05a941d)

Note: ReplaceAPI.replace no longer selects the closest match and only returns its index. Call ReplaceAPI.selectMatch afterwards if an index was returned instead.

Release 3.2.0

26 Mar 17:16
Compare
Choose a tag to compare

New features

Added comment toggling, automatic indentation, and tag-closing to nearly all languages. Previously this was only present in markup, markdown, xml, css, jsx, tsx, python and some c-like languages (18e814c)

Added two parameters to the matchBrackets() extension used to customize which punctuation tokens can be matched together. The extension now searches both the first and last characters in punctuation tokens instead of just the last character. This comes at a slight performance cost, but only testing the last character didn't work for a few languages (64c6041)

Added the ending position of the bracket to the Bracket type (64c6041)

Changes

The fullEditor() setup along with its web component have been marked as deprecated. This is because they'll get merged together with the basicEditor() setup in the next major release (2897736)

The NPM package no longer contains minified JavaScript code (#7) (56907f1)

Improvements

  • Improved patterns of multiline tokens in Haml, Pug and Sass grammars (fb025d9, 9e7f0f2)
  • Added bracket comments to CMake (c3c7614)
  • Small refactors to many Prism grammars (0cebe12)
  • Whitespace is no longer required between attributes in JSX tags (0a1d28a)
  • Improved escaping of braces in XQuery using {{ (4672340)

Better templating (7943a7c)

The placeholders for the templating are now simply whitespace instead of looking like ___PH0___. This has multiple advantages:

  1. It works with all grammars. Previously, grammars that could split the placeholders into multiple tokens couldn't be used as host grammars.
  2. It's less complex, requiring significantly less code.
  3. It sometimes leads to better highlighting.

Additionally, recursion was used to insert multiple placeholders into the same string. Highlighting '<??>'.repeat(5000) with PHP would therefore lead to a stack overflow. Rewriting this to a loop fixes the potential stack overflows and improves performance. In most cases the performance increase is in the ballpark of 10-20%, but in best-case scenarios it can be multiple times faster.

Bug fixes

  • Fixed selection often being incorrect after an undo (fc3c678, e4382f5)
  • JSX tags with a block comment at the end like <div /* */> no longer behave like self-closing tags (0a1d28a)
  • JSX fragments now automatically close when typing
  • HTML tags such as <a href=foo/> no longer behave like self-closing tags (0a1d28a)
  • Self closing tags are no longer case sensitive, so for example <INPUT> would be self-closing in HTML (0a1d28a)

Release 3.1.1

13 Mar 14:57
Compare
Choose a tag to compare

Fix tooltips that broke in version 3.1.0 (8eb668f)

Release 3.1.0

12 Mar 23:24
Compare
Choose a tag to compare

New features

History extension

Previously, the browser's native undo/redo was used. While this often worked well enough, it has its limitations. In Chrome and Safari, all form elements share the same undo stack, and in Firefox, hiding an element with display: none would clear its undo history. The new history extension has none of these issues. You can even transfer the history from an editor to another, but not without breaking the old editor.

The extension is tiny. Adding it to the demo website, only increases its JS bundle by 0.35kB gzipped.

The history extension has been added to the basic setup and the full setup. The extension can be accessed from PrismEditor.extensions.

// Here's how to import the extension
import { editHistory } from "prism-code-editor/commands"

New theme

Prism's Tomorrow Night theme has been implemented. It's on the demo website if you want to try it.

Note: I forgot to add this file to the package. This was fixed in 3.1.2

import "prism-code-editor/themes/prism-tomorrow.css"

Improvements

  • Significantly increased performance of the getClosestToken() utility, especially for long lines. This was achieved by using a TreeWalker for the searching instead of using querySelector() coupled with Range.toString() to find the position of the tokens. The performance increase can be anywhere from a few times faster for short lines to a greater than 100x improvement for lines 1000s of characters long. Not sure why you'd view minified code in an editor, but that will perform much better now (9f8ebe6)
  • Decreased gzipped size of all Prism languages by more than 10kB (5%) through refactoring and optimization.
  • An input event on the textarea now always updates the editor even if its value didn't change (7a3ddef)

Fixes

  • Added .js extensions to most imports. The type declarations now work properly with a moduleResolution of NodeNext or Node16 (b94978b)
  • Added type="button" to the copy button and all buttons in the search widget. If you had an editor inside a form, these buttons would previously submit the form when clicked. This is no longer the case (8ea416b)
  • Fixed potential empty matches that could lead to buggy highlighting in multiple languages (b28da8d)
  • The getLanguage() utility now supports languages with hyphens in their name (d214971)
  • Changed the default tab size of the web components from 0 to 2 spaces. This wasn't a big issue since 0 would internally be replaced with 2 (e2ad6e5)
  • Fixed alignment issue with the highlightSelectionMatches() extension in RTL mode (741bc85)
  • Fixed incorrect highlighting of capitalized generic functions in the TSX language (bf85599)
  • Added a language-jsx alias to spread tokens inside JSX tags (bf85599)

Search widget improvments

  • Selection change handlers no longer run with the incorrect selection after calling the insertText() utility if the search widget is open (7a3ddef)
  • Selection matches are no longer highlighted after replacing a match with the search widget (7a3ddef)
  • The keyboard shortcuts for the 4 toggle buttons now uses keyCode instead of code on Mac. This will work better with non-QWERTY keyboards on Mac (7a3ddef)

Release 3.0.1

16 Feb 17:51
Compare
Choose a tag to compare
  • Fenced code blocks with more than three backticks are now supported in markdown (e40eaa7)
  • Fixed empty script/style tags potentially breaking the highlighting of css/js inside later script/style tags (b84f011)
  • The bracket level no longer gets reset back to zero when entering a nested token, so the rainbow brackets now work as expected again (0f304a2)
  • The search match selected while typing in the search widget is now the match closest to where the cursor was last time the editor was focused. This means the editor's cursor will jump less around while searching (eb00bbc)

Release 3.0.0

09 Feb 22:28
6a1a693
Compare
Choose a tag to compare

Breaking changes

The modified Prism instance has been significantly changed and more of Prism v2's features have been added, most notably custom tokenizers. Below is a list of most changes:

  • Everything Prism related is now exported from its own entry point prism-code-editor/prism
  • Prism grammars have been moved from prism-code-editor/grammars/* to prism-code-editor/prism/languages/*
  • The rest property of grammars is now a rest symbol
  • Added custom tokenizers to grammars through a tokenize symbol
  • Grammar related utilities like clone, extend and insertBefore are now found under prism-code-editor/prism/utils
  • Changed the signature of the insertBefore utility
  • Prism hooks have been removed since they were unused by all languages
  • Dropped the @types/prismjs dependency since it's incompatible
  • Moved the attr-equals token out of attr-value in the markup/xml grammar. This can change some themes
  • Dropped support for CRLF and CR line breaks in all grammars
  • Dropped the clike dependency from the following languages: c, dart, fsharp, go, groovy, haxe, java, jolie, kotlin, latte, purebasic, qsharp, qore, ruby, sqf, squirrel, and vala
  • xml is now its own seperate language component that markup extends
  • Dropped the markup dependency from jsx
  • Removed the t4-templating language
  • js-extras has been removed and some of its features have been moved to the javascript grammar instead
  • The markup-templating language has been replaced by the embeddedIn utility
  • Empty tokens can no longer be created by the tokenizer because empty matches are skipped
  • The global regex flag on the pattern is now required for greedy tokens

Other breaking changes

There are also breaking changes unrelated to Prism:

  • Removed the TokenizeEnv type
  • Changed the arguments for tokenize listeners. Instead of a single TokenizeEnv argument, the tokens, language, and value are passed as individual arguments in the aforementioned order (25cd60f)
  • Moved ignoreTab and setIgnoreTab to prism-code-editor/commands (84b2515)
  • Removed support for a number as a search filter (ebc89fa)
  • Changed the order of properties in the Tag tuples created by the tag matcher to be more sensible
  • Moved the pce-readonly and pce-no-selection classes from the overlays to the scroll container. You might need to change some CSS selectors
  • The editor used is now passed as an third argument to the autoIndent and autoCloseTags methods instead of being passed through this (73e082e)
  • The InputSelection type has been made mutable (c48443e)
  • createTagMatcher no longer writes to editor.extensions.matchTags
  • Changed the classname of the tooltip container from tooltip-wrapper to pce-tooltip to avoid potential style collisions with external style sheets
  • Added overflow-x: clip to the tooltip container by default to prevent overflow in modern browsers

New features

  • New public highlightText and highlightTokens functions allow you to easily do syntax highlighting outside of an editor
  • You can now use this library's Prism instance to do syntax highlighting in Node.js
  • Tags aren't automatically closed while typing if there exists an unmatched closing tag with the same name. This is only the case with the tag matching extension added
  • Added the class pce-focus to the editor when it's focused
  • Plain functions can now be used as editor extensions. These functions take the same arguments as the update method on the existing extensions, but won't be called again when the editor's options change

Fixes and improvements

  • The tag- and bracket matching can no longer match together tags/brackets with different parent tokens
  • The jsdoc language now works with jsx and tsx
  • Bracket matching has been enabled inside regex tokens
  • Improved highlighting of regex tokens in all themes
  • Added the missing property rtl to the PrismEditorElement type (34ed0ff)
  • Fixed alignment issue with the highlightCurrentWord extension in RTL mode (1f7611d)
  • Almost any operator or punctuation is now allowed after javascript regex tokens (d88a25a)
  • Fixed a very rare edge case where new highlighted lines would be inserted in the wrong position (326e6fc)
  • Fixed issue with the markdown code block punctuation pattern (c7b9f7c)
  • The Prism core is now almost 20% smaller and slightly faster than before (d142f64)

Website

  • Added the jsdoc, js-templates, and regex languages
  • Added a tooltip to the bottom read-only editor to tell users it can't be edited

Release 2.4.1

18 Jan 23:34
Compare
Choose a tag to compare

Fixed issue where JSX fragments weren't matched by the tag matcher (a90b5c2)
Fixed bug with multiple commands executed at the start of the first line (54ff612)