Release 3.0.0
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/*
toprism-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
andinsertBefore
are now found underprism-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 ofattr-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
, andvala
xml
is now its own seperate language component thatmarkup
extends- Dropped the
markup
dependency fromjsx
- Removed the
t4-templating
language js-extras
has been removed and some of its features have been moved to thejavascript
grammar instead- The
markup-templating
language has been replaced by theembeddedIn
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 singleTokenizeEnv
argument, the tokens, language, and value are passed as individual arguments in the aforementioned order (25cd60f) - Moved
ignoreTab
andsetIgnoreTab
toprism-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
andpce-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
andautoCloseTags
methods instead of being passed throughthis
(73e082e) - The
InputSelection
type has been made mutable (c48443e) createTagMatcher
no longer writes toeditor.extensions.matchTags
- Changed the classname of the tooltip container from
tooltip-wrapper
topce-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
andhighlightTokens
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 withjsx
andtsx
- Bracket matching has been enabled inside regex tokens
- Improved highlighting of regex tokens in all themes
- Added the missing property
rtl
to thePrismEditorElement
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
, andregex
languages - Added a tooltip to the bottom read-only editor to tell users it can't be edited