Skip to content

Releases: FIameCaster/prism-code-editor

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)

Release 2.4.0

18 Jan 15:30
Compare
Choose a tag to compare

New features

Better comment toggling for JSX

When inside a JSX context, normal JavaScript comments can't be used. Therefore {/* */} comments will now be used in JSX contexts.(2e38fd2)

A new property on languages getComments was used to make this possible. You can read about it in the API docs.

New commands

  • Shift+Ctrl+K (Shift+Cmd+K on MacOS): Delete line (617da31)
  • Ctrl+Enter (Cmd+Enter on MacOS) Insert blank line (7ee34a4)

Fixes

  • Tag matching and block comment folding now works properly in nested languages (9bab6a3)
  • The JS templates and markup templating Prism languages can no longer break tag matching, bracket matching and code folding

Release 2.3.2

05 Jan 23:20
Compare
Choose a tag to compare

Fixed highlighting when there are tags inside object spread in JSX tags (9ec5299)
Fixed backtracking issues with the new tag patterns for JSX and markup
Improved an edge case when toggling comments in languages without line comments such as CSS or markup (edcc167)
Fixed a bug in the Prism core where the rest property of grammars wasn't ignored by the matchGrammar function

Release 2.3.1

27 Dec 23:36
Compare
Choose a tag to compare
  • Fixed an issue with the TSX tag pattern's lookbehind in Safari (ad82bd0)
  • Carriage returns in the value option are now supported (32dd207)
  • Improved behavior in multiple edge cases when toggling comments or indenting with Tab (03dfdda)

Release 2.3.0

21 Dec 22:13
Compare
Choose a tag to compare

New features

  • Added a parameter to SearchAPI.search which allows you to change the behavior of whole word search (a585839)
  • The highlightSelectionMatches and highlightCurrentWord extensions now expose their search API which can be used to e.g. get the positions of the current matches (38e9f0b)
  • Added source maps to the package for easier debugging (35c96d3)

Improvements and fixes

  • The matchTags extension now correctly handles name spaced tags and matches tags inside attribute values (3e55338)
  • Improved the tag pattern i both JSX and markup. The attribute value has been made optional, and whitespace is now allowed around =, so <div id=> and <div id = "a"> are now highlighted as tags which improves typing experience. Lastly, JSX tag names and attribute names now allow non-ASCII characters (5553f09)
  • Small improvements to the JavaScript grammar (5553f09)
  • Improved word boundries for searching in the highlightCurrentWord extension (ea955f7)
  • Fixed a couple bugs in the highlightTagPunctuation extension (6dbdb27)
  • Creating an editor or calling setOptions with the value option explicitly set to undefined no longer throws an error (5faa832)
  • Constants are now colored differently in the VS Code Light/Dark themes (2f4f534)

Release 2.2.4

10 Dec 15:28
Compare
Choose a tag to compare
  • Improved whole word search behavior
  • A Chrome bug patch for the search widget didn't always work. It now does

Release 2.2.3

03 Dec 16:26
Compare
Choose a tag to compare
  • Fixed PrismJS/prism#3722 for the Kotlin grammar
  • Improved whole word search
  • Opening the search widget programmatically now starts a search with the find input's contents.
  • Fixed opening punctuation of JSX fragments being highlighted by the matchTags extension