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

@replit/codemirror-interact

Package Overview
Dependencies
Maintainers
23
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@replit/codemirror-interact - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

19

dist/index.js
import { Decoration, EditorView, ViewPlugin } from '@codemirror/view';
import { StateEffect, Facet } from '@codemirror/state';
import { StateEffect, Facet, Compartment, Prec } from '@codemirror/state';
// TODO: don't use document.style.cursor
// TODO: custom style
const mark = /*@__PURE__*/Decoration.mark({ class: 'cm-interact' });

@@ -37,2 +37,8 @@ const setInteract = /*@__PURE__*/StateEffect.define();

});
const setStyle = (style = '') => EditorView.contentAttributes.of({ style });
const normalCursor = /*@__PURE__*/setStyle();
const cursorCompartment = /*@__PURE__*/new Compartment();
const cursorRule = /*@__PURE__*/Prec.highest(/*@__PURE__*/cursorCompartment.of(normalCursor));
const clearCursor = () => cursorCompartment.reconfigure(normalCursor);
const setCursor = (cursor) => cursor ? [cursorCompartment.reconfigure(setStyle(`cursor: ${cursor}`))] : [];
const interactViewPlugin = /*@__PURE__*/ViewPlugin.define((view) => ({

@@ -90,13 +96,9 @@ dragging: null,

highlight(target) {
if (target.rule.cursor) {
document.body.style.cursor = target.rule.cursor;
}
view.dispatch({
effects: setInteract.of(target),
effects: [setInteract.of(target), ...setCursor(target.rule.cursor)],
});
},
unhighlight() {
document.body.style.cursor = 'auto';
view.dispatch({
effects: setInteract.of(null),
effects: [setInteract.of(null), clearCursor()],
});

@@ -198,2 +200,3 @@ },

interactModKey.of((_a = cfg.key) !== null && _a !== void 0 ? _a : "alt"),
cursorRule,
((_b = cfg.rules) !== null && _b !== void 0 ? _b : []).map((r) => interactRule.of(r)),

@@ -200,0 +203,0 @@ ];

{
"name": "@replit/codemirror-interact",
"description": "Interact with custom values",
"version": "6.0.2",
"version": "6.0.3",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": {

@@ -1,2 +0,1 @@

// TODO: don't use document.style.cursor
// TODO: custom style

@@ -14,2 +13,4 @@ // TODO: custom state for each rule?

Facet,
Prec,
Compartment,
} from '@codemirror/state'

@@ -67,2 +68,14 @@

const setStyle = (style = '') =>
EditorView.contentAttributes.of({ style });
const normalCursor = setStyle();
const cursorCompartment = new Compartment();
const cursorRule = Prec.highest(cursorCompartment.of(normalCursor));
const clearCursor = () => cursorCompartment.reconfigure(normalCursor);
const setCursor = (cursor?: string) =>
cursor ? [cursorCompartment.reconfigure(setStyle(`cursor: ${cursor}`))] : [];
interface ViewState extends PluginValue {

@@ -137,7 +150,4 @@ dragging: Target | null,

highlight(target) {
if (target.rule.cursor) {
document.body.style.cursor = target.rule.cursor;
}
view.dispatch({
effects: setInteract.of(target),
effects: [setInteract.of(target), ...setCursor(target.rule.cursor)],
});

@@ -147,5 +157,4 @@ },

unhighlight() {
document.body.style.cursor = 'auto'
view.dispatch({
effects: setInteract.of(null),
effects: [setInteract.of(null), clearCursor()],
});

@@ -274,2 +283,3 @@ },

interactModKey.of(cfg.key ?? "alt"),
cursorRule,
(cfg.rules ?? []).map((r) => interactRule.of(r)),

@@ -276,0 +286,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