Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
FIameCaster committed Jan 5, 2024
1 parent 0c3db37 commit 1269ce7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prism-code-editor",
"version": "2.3.1",
"version": "2.3.2",
"type": "module",
"description": "Lightweight, extensible code editor component for the web using Prism",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const createEditor = (
})
},
addListener<T extends keyof EditorEventMap>(name: T, handler: EditorEventMap[T]) {
;(listeners[name] || (listeners[name] = <any>new Set())).add(handler)
;(listeners[name] ||= new Set<any>()).add(handler)
},
removeListener<T extends keyof EditorEventMap>(name: T, handler: EditorEventMap[T]) {
listeners[name]?.delete(handler)
Expand Down
8 changes: 3 additions & 5 deletions package/src/languages/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { languageMap } from "../core"
import { clikeIndent, isBracketPair } from "./patterns"

const openingTag =
/(?:^|[^\w$])<(?:(?!\d)([^\s>\/=<%]+)(?:(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)+(?:[^\s{*>\/=]+(?:(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)*=\s*(?:"[^"]*"|'[^']*'|[^\s{'"\/>=]+|(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})))?|(?:\{(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\.{3}(?:[^{}]|(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\}))*\})))*(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)*)?>[ \t]*$/
/(?:^|[^\w$])<(?:(?!\d)([^\s>\/=<%]+)(?:(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)+(?:[^\s{*<>\/=]+(?:(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)*=\s*(?:"[^"]*"|'[^']*'|[^\s{'"\/>=]+|(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})))?|(?:\{(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\.{3}(?:[^{}]|(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\}))*\})))*(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\/)*)?>[ \t]*$/

const closingTag = /^<\/(?!\d)[^\s>\/=<%]*\s*>/

Expand All @@ -12,12 +12,10 @@ languageMap.jsx = languageMap.tsx = {
block: ["/*", "*/"],
},
autoIndent: [
([start], value) =>
openingTag.test((value = value.slice(0, start))) || clikeIndent.test(value),
([start], value) => openingTag.test((value = value.slice(0, start))) || clikeIndent.test(value),
([start, end], value) =>
isBracketPair.test(value[start - 1] + value[end]) ||
(openingTag.test(value.slice(0, start)) &&
closingTag.test(value.slice(end))),
(openingTag.test(value.slice(0, start)) && closingTag.test(value.slice(end))),
],
autoCloseTags([start, end], value) {
const match = start == end && (value.slice(0, start) + ">").match(openingTag)
Expand Down
9 changes: 6 additions & 3 deletions package/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export type Language = {
autoCloseTags?(this: PrismEditor, selection: InputSelection, value: string): string | undefined
}

export type PrismType = Omit<typeof Prism, "highlight" | "highlightAll" | "highlightAllUnder" | "highlightElement">
export type PrismType = Omit<
typeof Prism,
"highlight" | "highlightAll" | "highlightAllUnder" | "highlightElement"
>
/**
* Function called when a certain key is pressed.
* If true is returned, `e.preventDefault()` and `e.stopImmediatePropagation()` is called automatically.
Expand Down Expand Up @@ -102,8 +105,8 @@ export interface PrismEditor extends EventHandler<EditorEventMap> {
readonly scrollContainer: HTMLDivElement
/** Element wrapping the lines and overlays. */
readonly wrapper: HTMLDivElement
/**
* Element containing overlays that are absolutely positioned ontop or underneath the code.
/**
* Element containing overlays that are absolutely positioned ontop or behind the code.
* It is completely safe to append your own overlays to this element, but they will get
* some default styles.
*/
Expand Down

0 comments on commit 1269ce7

Please sign in to comment.