Socket
Socket
Sign inDemoInstall

@codemirror/fold

Package Overview
Dependencies
10
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.17.1 to 0.18.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 0.18.0 (2021-03-03)
### Bug fixes
Adds a screen reader announcement when code is folded or unfolded.
## 0.17.1 (2021-01-06)

@@ -2,0 +8,0 @@

27

dist/index.js
import { StateEffect, StateField, Facet, combineConfig } from '@codemirror/state';
import { Decoration, EditorView, WidgetType, themeClass, ViewPlugin } from '@codemirror/view';
import { Decoration, EditorView, WidgetType, ViewPlugin } from '@codemirror/view';
import { foldable } from '@codemirror/language';

@@ -57,3 +57,3 @@ import { gutter, GutterMarker } from '@codemirror/gutter';

if (!found || found.from > from)
found = ({ from, to });
found = { from, to };
});

@@ -68,4 +68,4 @@ return found;

}
function maybeEnable(state) {
return state.field(foldState, false) ? undefined : { append: codeFolding() };
function maybeEnable(state, other) {
return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));
}

@@ -77,4 +77,3 @@ /// Fold the lines that are selected, if possible.

if (range) {
view.dispatch({ effects: foldEffect.of(range),
reconfigure: maybeEnable(view.state) });
view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
return true;

@@ -93,3 +92,3 @@ }

if (folded)
effects.push(unfoldEffect.of(folded));
effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
}

@@ -100,2 +99,6 @@ if (effects.length)

};
function announceFold(view, range, fold = true) {
let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
return EditorView.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
}
/// Fold all top-level foldable ranges.

@@ -111,3 +114,3 @@ const foldAll = view => {

if (effects.length)
view.dispatch({ effects, reconfigure: maybeEnable(view.state) });
view.dispatch({ effects: maybeEnable(view.state, effects) });
return !!effects.length;

@@ -161,3 +164,3 @@ };

element.title = state.phrase("unfold");
element.className = themeClass("foldPlaceholder");
element.className = "cm-foldPlaceholder";
element.onclick = event => {

@@ -236,3 +239,3 @@ let line = view.visualLineAt(view.posAtDOM(event.target));

gutter({
style: "foldGutter",
class: "cm-foldGutter",
markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },

@@ -262,3 +265,3 @@ initialSpacer() {

const baseTheme = EditorView.baseTheme({
$foldPlaceholder: {
".cm-foldPlaceholder": {
backgroundColor: "#eee",

@@ -272,3 +275,3 @@ border: "1px solid #ddd",

},
"$gutterElement.foldGutter": {
".cm-foldGutter .cm-gutterElement": {
padding: "0 1px",

@@ -275,0 +278,0 @@ cursor: "pointer"

{
"name": "@codemirror/fold",
"version": "0.17.1",
"version": "0.18.0",
"description": "Code folding for the CodeMirror code editor",

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

"dependencies": {
"@codemirror/gutter": "^0.17.0",
"@codemirror/language": "^0.17.0",
"@codemirror/rangeset": "^0.17.0",
"@codemirror/state": "^0.17.0",
"@codemirror/view": "^0.17.0"
"@codemirror/gutter": "^0.18.0",
"@codemirror/language": "^0.18.0",
"@codemirror/rangeset": "^0.18.0",
"@codemirror/state": "^0.18.0",
"@codemirror/view": "^0.18.0"
},

@@ -36,0 +36,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc