Releases: FIameCaster/prism-code-editor
Release 2.2.2
- Fix empty search match before UTF-16 surrogate pair causing infinite loop (5fa8c2c)
- Search filter is now called with the correct start and end parameters when only a part of the document is searched (5fa8c2c)
- Slightly altered appearance of empty search matches (5fa8c2c)
- Improved javascript template strings. Previously strings with empty interpolation expressions such as
`a${}b`
would not be highlighted as a template string. Now it will be, improving UX while typing (3887da8)
Release 2.2.1
Release 2.2.0
Improvements
Including hyphens in the search wasn't wanted for most languages. Therefore a new parameter was added to the highlightCurrentWord
extension.
const selector = ".string, .comment, .keyword, .regex"
const filter = start => !getClosestToken(editor, selector, 0, 0, start)
const includeHyphens = position => getLanguage(editor, position) == "css"
editor.addExtensions(
highlightCurrentWord(filter, includeHyphens)
)
Fixes
In TSX, opening tags comming directly after another tag are now highlighted. This was an issue with Prism's TSX grammar.
Release 2.1.0
New features
- Added a word highlighting extension.
import { highlightCurrentWord } from "prism-code-editor/search"
const selector = ".string, .comment, .keyword, .regex"
const filter = start => !getClosestToken(editor, selector, 0, 0, start)
editor.addExtensions(
highlightCurrentWord(filter)
)
- Added a filter parameter to
SearchAPI.search
(6786676)
Fixes/improvements
Release 2.0.0
New features
Re-exporting Prism's grammars
Prism's grammars are now re-exported. These grammars automatically import required dependencies. Optional dependencies are handled at runtime, so import order usually won't matter.
import "prism-code-editor/grammars/markup"
import "prism-code-editor/grammars/css-extras"
import "prism-code-editor/grammars/js-extras"
This means prismjs
is now longer a necessary dependency in your projects.
Bracket matching in markup
Bracket matching has been added to markup languages like HTML by modifying their grammars. All themes style these brackets with color: inherit
to disable rainbow brackets. If you want to style them, use the CSS selector .token.markup-bracket.punctuation
.
Extra folding features
You can now import a provider that allows folding of titles and code blocks in markdown. Folding of block comments is now optional. To enable them, pass them to the readOnlyCodeFolding
extension when creating it.
import {
markdownFolding, blockCommentFolding, readOnlyCodeFolding
} from "prism-code-editor/code-folding"
import "prism-code-editor/languages/html"
const editor = createEditor(
"#editor",
{ language: "markdown" },
readOnlyCodeFolding(markdownFolding, blockCommentFolding)
)
New tag highlighting feature
Added an extension that highlights <
and >
punctuation in XML tags.
import { highlightTagPunctuation } from "prism-code-editor/match-tags"
Breaking changes
- It's no longer possible to use your own Prism instance.
- You can now longer import languages from
prismjs
without definingwindow.Prism
. Import languages fromprism-code-editor/grammars/*
instead. prism-code-editor/prism-core
has been removed. If you want access to the Prism instance, import it fromprism-code-editor
instead.prism-code-editor/prism-markdown
has been removed too. Importprism-code-editor/grammars/markdown
instead.- The
Prism
parameter has been removed from all functions in the library which simplifies many APIs. - The
languages
import from the core has now been renamed tolanguageMap
. - The utilities
regexEscape
,getLineBefore
,getLines
,getClosestToken
,getLanguage
,insertText
andgetModifierCode
are now exported fromprism-code-editor/utils
instead of the core.
Changed class names
Most class names have been prefixed to make style conflicts much less likely. If you've overridden some of the styles, chances are you'll need to change some selectors. Here's a list of all classes that have been changed:
prism-editor
toprism-code-editor
prism-editor-wrapper
topce-wrapper
editor-overlays
topce-overlays
code-line
topce-line
word-wrap
topce-wrap
no-word-wrap
topce-nowrap
readonly
topce-readonly
no-selection
topce-no-selection
rtl-editor
topce-rtl
search-input
topce-input
use-regexp
topce-regex
whole-word
topce-whole
find-in-selection
topce-in-selection
match-count
topce-match-count
search-options
topce-options
find
topce-find
replace
topce-replace
has-error
topce-error
search-matches
topce-matches
editor-copy
topce-copy
fold-placeholder
topce-unfold
fold-line-btn
topce-fold
Improvements/fixes
- The
matchTags
extensions would add a new selection change handler every timeeditor.setOptions
was called. This has been fixed. - The multiline flag is now enabled when doing RegExp search in the search widget. This means that
^
and$
now match the beginning/end on lines instead of the whole code. - The
$
character is now escaped when executing replace all in the search widget since it has special functionality. - Tag matching now works with all languages instead of just a handful.
- Changed the default margin on
.pce-wrapper
from0.75em 0
to0.5em 0
. - Fixed a Safari bug where the search highlight wouldn't be removed when switching focus back to the editor.
- Small improvements to most of the themes.
Release 1.2.2
Fixes
- Fixed a bug in
Prism.languages.insertBefore
in the patched Prism core. This didn't cause issues with many languages which is why it wasn't spotted before. - Fixed a typo in the patched markdown language which gave code blocks the wrong class name.
Improvements
- Small improvements to the
prism
,prism-okaidia
,night-owl
,vs-code-light
,vs-code-dark
andgithub-light
themes. - Big improvements to the
atom-one-dark
theme. - Refactored some extensions for a smaller bundle size.
Release 1.2.1
No changes to functionality, just improvements to the documentation.
Release 1.2.0
New features
- Added RTL directionality support thtough an optional extra stylesheet. Currently experimental due to multiple browser bugs.
import "prism-code-editor/rtl-layout.css"
- Added a wrapper around
createEditor
that replaces the element with the editor instead of appending the editor to it.
import { editorFromPlaceholder } from "prism-code-editor"
const editor = editorFromPlaceholder(Prism, "#editor", { language: "javascript" })
Fixes
aria-readonly="true"
is now added to thetextarea
when in read-only mode.- An error is no longer thrown when an editor is created with exactly two lines of code.
Release 1.1.0
New features
- Added a utility for adding tooltips to an editor.
import { addTooltip } from "prism-code-editor/tooltips"
const [show, hide] = addTooltip(editor, element)
- Added a utility that adds overscrolling to an editor, allowing users to scroll until the last line is at the top.
import { addOverscroll, removeOverscroll } from "prism-code-editor/tooltips"
addOverscroll(editor)
- Height property has been added when getting the cursor position.
Minor changes
- Read-only mode no longer uses the
readonly
attribute, instead cancellingbeforeinput
events. This will make read-only editors more interactive. - Automatically inserted closing tags are inserted immediately instead of after a 100ms delay.
- Improved titles when hovering over the fold buttons.
Fixes
- Small issues with
z-index
have been fixed. - Read-only editors no longer handle the Tab Key with the default commands added.
1.0.4
Fixed issue where the unfold button had position: static
resulting in its z-index
having no effect.
Improved scroll behavior in certain scenarios when hiding replace functionality in the search widget.