{"id":13752052,"url":"https://github.com/juliankrispel/react-text-selection-popover","last_synced_at":"2025-04-04T09:06:49.070Z","repository":{"id":32726200,"uuid":"140766145","full_name":"juliankrispel/react-text-selection-popover","owner":"juliankrispel","description":"Selection based Text UI made easy","archived":false,"fork":false,"pushed_at":"2023-01-09T10:13:32.000Z","size":3960,"stargazers_count":290,"open_issues_count":5,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T10:38:08.092Z","etag":null,"topics":["draft-js","popover","react","rich-text-editor","slatejs","text-editor","text-selection","wysiwyg-editor"],"latest_commit_sha":null,"homepage":"https://juliankrispel.github.io/react-text-selection-popover","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/juliankrispel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-12T21:24:21.000Z","updated_at":"2025-02-24T15:47:42.000Z","dependencies_parsed_at":"2023-01-14T22:15:29.271Z","dependency_job_id":null,"html_url":"https://github.com/juliankrispel/react-text-selection-popover","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliankrispel%2Freact-text-selection-popover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliankrispel%2Freact-text-selection-popover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliankrispel%2Freact-text-selection-popover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliankrispel%2Freact-text-selection-popover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliankrispel","download_url":"https://codeload.github.com/juliankrispel/react-text-selection-popover/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149500,"owners_count":20891954,"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":["draft-js","popover","react","rich-text-editor","slatejs","text-editor","text-selection","wysiwyg-editor"],"created_at":"2024-08-03T09:00:58.702Z","updated_at":"2025-04-04T09:06:49.042Z","avatar_url":"https://github.com/juliankrispel.png","language":"TypeScript","funding_links":[],"categories":["*.js"],"sub_categories":["React"],"readme":"# react-text-selection-popover\n\nA react component that lets you render a popover in relation to the current text selection. \n\n[![NPM](https://img.shields.io/npm/v/react-text-selection-popover.svg)](https://www.npmjs.com/package/react-text-selection-popover) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n\n## Install\n\n```bash\nnpm install --save react-text-selection-popover\n```\n\n## Usage\n\n```tsx\nimport css from '@emotion/css'\n\n\u003cPopover\n  render={\n    ({ clientRect, isCollapsed, textContent }) =\u003e {\n      if (clientRect == null || isCollapsed) return null\n\n      // I'm using emotion for this example but you can use anything really\n      const style = css`\n        position: absolute;\n        left: ${clientRect.left + clientRect.width / 2}px;\n        top: ${clientRect.top - 40}px;\n        margin-left: -75px;\n        width: 150px;\n        background: blue;\n        font-size: 0.7em;\n        pointer-events: none;\n        text-align: center;\n        color: white;\n        border-radius: 3px;\n      `\n\n      return \u003cdiv className={style}\u003e\n        Selecting {(textContent || '').length} characters\n      \u003c/div\u003e\n    }\n  }\n/\u003e\n```\n\n### Props\n\n| name | type | description |\n| --- | ---- | --- |\n| `render`  | `({ clientRect, isCollapsed, textContent }) =\u003e {}` | __required__ Render prop for rendering your popover, see above for usage |\n| `mount`     | `HTMLElement` |  Dom Element that Popover will be rendered into (This component uses [React Portals](https://reactjs.org/docs/portals.html). Defaults to `document.body` |\n| `target`    | `HTMLElement` | Dom Element which the popover is constrained to |\n\n# Shoutouts\n\nThis was originally written during some freelance work for [Spectrum](https://spectrum.chat/). Shoutout to their awesomeness for letting me do all my work for them in the open!\n\n## Work with me?\n\nI build editors for companies, or help their teams do so. Hit me up on [my website](http://jkrsp.com) to get in touch about a project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliankrispel%2Freact-text-selection-popover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliankrispel%2Freact-text-selection-popover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliankrispel%2Freact-text-selection-popover/lists"}