Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/search

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/search - npm Package Compare versions

Comparing version 0.20.1 to 6.0.0

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## 6.0.0 (2022-06-08)
### Bug fixes
Don't crash when a custom search panel doesn't have a field named 'search'.
Make sure replacements are announced to screen readers.
## 0.20.1 (2022-04-22)

@@ -2,0 +10,0 @@

20

dist/index.js

@@ -853,2 +853,3 @@ import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view';

let changes = [], selection, replacement;
let announce = [];
if (next.from == from && next.to == to) {

@@ -858,2 +859,3 @@ replacement = state.toText(query.getReplacement(next));

next = query.nextMatch(state.doc, next.from, next.to);
announce.push(EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
}

@@ -863,2 +865,3 @@ if (next) {

selection = { anchor: next.from - off, head: next.to - off };
announce.push(announceMatch(view, next));
}

@@ -868,3 +871,3 @@ view.dispatch({

scrollIntoView: !!selection,
effects: next ? announceMatch(view, next) : undefined,
effects: announce,
userEvent: "input.replace"

@@ -887,4 +890,6 @@ });

return false;
let announceText = view.state.phrase("replaced $ matches", changes.length) + ".";
view.dispatch({
changes,
effects: EditorView.announce.of(announceText),
userEvent: "input.replace.all"

@@ -913,4 +918,4 @@ });

return false;
let searchInput = panel.dom.querySelector("[name=search]");
if (searchInput != view.root.activeElement) {
let searchInput = panel.dom.querySelector("[main-field]");
if (searchInput && searchInput != view.root.activeElement) {
let query = defaultQuery(view.state, state.query.spec);

@@ -973,2 +978,3 @@ if (query.valid)

name: "search",
"main-field": "true",
onchange: this.commit,

@@ -1071,6 +1077,6 @@ onkeyup: this.commit

function announceMatch(view, { from, to }) {
let lineStart = view.state.doc.lineAt(from).from, lineEnd = view.state.doc.lineAt(to).to;
let start = Math.max(lineStart, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);
let line = view.state.doc.lineAt(from), lineEnd = view.state.doc.lineAt(to).to;
let start = Math.max(line.from, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);
let text = view.state.sliceDoc(start, end);
if (start != lineStart) {
if (start != line.from) {
for (let i = 0; i < AnnounceMargin; i++)

@@ -1089,3 +1095,3 @@ if (!Break.test(text[i + 1]) && Break.test(text[i])) {

}
return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${view.state.doc.lineAt(from).number}`);
return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${line.number}.`);
}

@@ -1092,0 +1098,0 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({

{
"name": "@codemirror/search",
"version": "0.20.1",
"version": "6.0.0",
"description": "Search functionality for the CodeMirror code editor",

@@ -29,4 +29,4 @@ "scripts": {

"dependencies": {
"@codemirror/state": "^0.20.0",
"@codemirror/view": "^0.20.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"

@@ -33,0 +33,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc