Skip to content

Commit

Permalink
Add getDrawSelectionConfig
Browse files Browse the repository at this point in the history
FEATURE: The new `getDrawSelectionConfig` function returns the `drawSelection`
configuration for a given state.

See https://discuss.codemirror.net/t/how-to-get-cursor-blinking-rate-in-another-extension/7077
  • Loading branch information
marijnh committed Sep 20, 2023
1 parent bdd2f10 commit c0e108a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ component that displays the editor state and allows text input.

@drawSelection

@getDrawSelectionConfig

@dropCursor

@highlightActiveLine
Expand Down
7 changes: 7 additions & 0 deletions src/draw-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export function drawSelection(config: SelectionConfig = {}): Extension {
]
}

/// Retrieve the [`drawSelection`](#view.drawSelection) configuration
/// for this state. (Note that this will return a set of defaults even
/// if `drawSelection` isn't enabled.)
export function getDrawSelectionConfig(state: EditorState): SelectionConfig {
return state.facet(selectionConfig)
}

function configChanged(update: ViewUpdate) {
return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig)
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {BlockInfo} from "./heightmap"
export {MouseSelectionStyle} from "./input"
export {BidiSpan, Direction} from "./bidi"
export {KeyBinding, keymap, runScopeHandlers} from "./keymap"
export {drawSelection} from "./draw-selection"
export {drawSelection, getDrawSelectionConfig} from "./draw-selection"
export {dropCursor} from "./dropcursor"
export {highlightSpecialChars} from "./special-chars"
export {scrollPastEnd} from "./scrollpastend"
Expand Down

0 comments on commit c0e108a

Please sign in to comment.