{"id":18562481,"url":"https://github.com/replit/codemirror-interact","last_synced_at":"2025-04-13T09:12:41.525Z","repository":{"id":38834943,"uuid":"440311240","full_name":"replit/codemirror-interact","owner":"replit","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-19T17:15:52.000Z","size":254,"stargazers_count":118,"open_issues_count":7,"forks_count":5,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-04-13T09:12:35.177Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://replit.com/@util/codemirror-interact","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-20T21:28:06.000Z","updated_at":"2025-04-04T04:37:46.000Z","dependencies_parsed_at":"2024-03-26T16:52:38.796Z","dependency_job_id":"aab80726-a6ca-4918-993d-d2983438d76d","html_url":"https://github.com/replit/codemirror-interact","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-interact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-interact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-interact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fcodemirror-interact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replit","download_url":"https://codeload.github.com/replit/codemirror-interact/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688566,"owners_count":21145766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T22:09:52.773Z","updated_at":"2025-04-13T09:12:41.494Z","avatar_url":"https://github.com/replit.png","language":"TypeScript","readme":"# CodeMirror Interact\n\n\u003cspan\u003e\u003ca href=\"https://replit.com/@util/codemirror-interact\" title=\"Run on Replit badge\"\u003e\u003cimg src=\"https://replit.com/badge/github/replit/codemirror-interact\" alt=\"Run on Replit badge\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan\u003e\u003ca href=\"https://www.npmjs.com/package/@replit/codemirror-interact\" title=\"NPM version badge\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@replit/codemirror-interact?color=blue\" alt=\"NPM version badge\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\nA CodeMirror extension that lets you interact with different values (clicking, dragging, etc).\n\nhttps://user-images.githubusercontent.com/9929523/147966613-270cdece-564f-4906-b6e8-b48975a0d9e2.mp4\n\n[demo](https://replit.com/@util/codemirror-interact)\n\n### Usage\n\n```ts\nimport { EditorState } from '@codemirror/state';\nimport { EditorView } from '@codemirror/view';\nimport interact from '@replit/codemirror-interact';\n\n// hold Alt and drag / click values\nnew EditorView({\n  state: EditorState.create({\n    doc: 'const num = 123',\n    extensions: [\n      interact({\n        rules: [\n          // a rule for a number dragger\n          {\n            // the regexp matching the value\n            regexp: /-?\\b\\d+\\.?\\d*\\b/g,\n            // set cursor to \"ew-resize\" on hover\n            cursor: \"ew-resize\",\n            // change number value based on mouse X movement on drag\n            onDrag: (text, setText, e) =\u003e {\n              const newVal = Number(text) + e.movementX;\n              if (isNaN(newVal)) return;\n              setText(newVal.toString());\n            },\n          }\n        ],\n      }),\n    ],\n  }),\n  parent: document.querySelector('#editor'),\n});\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fcodemirror-interact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplit%2Fcodemirror-interact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fcodemirror-interact/lists"}