@codemirror/fold
Advanced tools
Comparing version 0.19.2 to 0.19.3
@@ -0,1 +1,7 @@ | ||
## 0.19.3 (2022-01-24) | ||
### New features | ||
`foldGutter` now takes a `domEventHandlers` option to register additional event handlers for the gutter. | ||
## 0.19.2 (2021-11-30) | ||
@@ -2,0 +8,0 @@ |
import * as _codemirror_state from '@codemirror/state'; | ||
import { EditorState, Extension } from '@codemirror/state'; | ||
import { DecorationSet, Command, KeyBinding, EditorView } from '@codemirror/view'; | ||
import { DecorationSet, Command, KeyBinding, EditorView, BlockInfo } from '@codemirror/view'; | ||
@@ -73,2 +73,5 @@ declare type DocRange = { | ||
declare function codeFolding(config?: FoldConfig): Extension; | ||
declare type Handlers = { | ||
[event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean; | ||
}; | ||
interface FoldGutterConfig { | ||
@@ -91,2 +94,6 @@ /** | ||
closedText?: string; | ||
/** | ||
Supply event handlers for DOM events on this gutter. | ||
*/ | ||
domEventHandlers?: Handlers; | ||
} | ||
@@ -93,0 +100,0 @@ /** |
@@ -177,3 +177,2 @@ import { StateEffect, StateField, Facet, combineConfig } from '@codemirror/state'; | ||
const foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType { | ||
ignoreEvents() { return false; } | ||
toDOM(view) { | ||
@@ -203,2 +202,3 @@ let { state } = view, conf = state.facet(foldConfig); | ||
markerDOM: null, | ||
domEventHandlers: {}, | ||
}; | ||
@@ -251,2 +251,3 @@ class FoldMarker extends GutterMarker { | ||
}); | ||
let { domEventHandlers } = fullConfig; | ||
return [ | ||
@@ -260,4 +261,5 @@ markers, | ||
}, | ||
domEventHandlers: { | ||
click: (view, line) => { | ||
domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => { | ||
if (domEventHandlers.click && domEventHandlers.click(view, line, event)) | ||
return true; | ||
let folded = foldInside(view.state, line.from, line.to); | ||
@@ -274,4 +276,3 @@ if (folded) { | ||
return false; | ||
} | ||
} | ||
} }) | ||
}), | ||
@@ -278,0 +279,0 @@ codeFolding() |
{ | ||
"name": "@codemirror/fold", | ||
"version": "0.19.2", | ||
"version": "0.19.3", | ||
"description": "Code folding for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
31435
692