Skip to content

Release 3.0.0

Compare
Choose a tag to compare
@FIameCaster FIameCaster released this 09 Feb 22:28
· 111 commits to main since this release
6a1a693

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