• Stars
    star
    288
  • Rank 143,818 (Top 3 %)
  • Language
    TypeScript
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Selection based Text UI made easy

react-text-selection-popover

A react component that lets you render a popover in relation to the current text selection.

NPM JavaScript Style Guide

Install

npm install --save react-text-selection-popover

Usage

import css from '@emotion/css'

<Popover
  render={
    ({ clientRect, isCollapsed, textContent }) => {
      if (clientRect == null || isCollapsed) return null

      // I'm using emotion for this example but you can use anything really
      const style = css`
        position: absolute;
        left: ${clientRect.left + clientRect.width / 2}px;
        top: ${clientRect.top - 40}px;
        margin-left: -75px;
        width: 150px;
        background: blue;
        font-size: 0.7em;
        pointer-events: none;
        text-align: center;
        color: white;
        border-radius: 3px;
      `

      return <div className={style}>
        Selecting {(textContent || '').length} characters
      </div>
    }
  }
/>

Props

name type description
render ({ clientRect, isCollapsed, textContent }) => {} required Render prop for rendering your popover, see above for usage
mount HTMLElement Dom Element that Popover will be rendered into (This component uses React Portals. Defaults to document.body
target HTMLElement Dom Element which the popover is constrained to

Shoutouts

This was originally written during some freelance work for Spectrum. Shoutout to their awesomeness for letting me do all my work for them in the open!

Work with me?

I build editors for companies, or help their teams do so. Hit me up on my website to get in touch about a project.

More Repositories

1

zettel

Javascript framework for writing rich text applications
TypeScript
78
star
2

redux-connector

A component wrapper for the connect method from react-redux, Using the renderProp pattern (PROOF OF CONCEPT)
JavaScript
63
star
3

use-text-selection

React hook for tracking text selection
TypeScript
35
star
4

slate-patterns

Patterns for slate.js
TypeScript
29
star
5

typescript-aws-lambda-terraform

Boilerplate for a serverless application on AWS using typescript, webpack and terraform.
JavaScript
21
star
6

s3-auto-sync

Watch a folder and upload changes to an s3 bucket.
JavaScript
19
star
7

basic-draft-js-tutorial

Beginner tutorial for draft-js
JavaScript
16
star
8

bishbosh

Proposal - BishBosh - A domain specific language for writing command line interfaces
HTML
13
star
9

draft-js-building-search-and-replace

Accompanying code for a tutorial on how to build search and replace functionality
JavaScript
8
star
10

draft-js-and-redux

Accompanying code for a tutorial on how to combine draft-js and redux.
JavaScript
7
star
11

getting-started-with-draft-js-plugins

Code for Tutorial - Getting Started with Draft-js-plugins
JavaScript
7
star
12

slate-js-boilerplate

Boilerplate for slate js editing projects
TypeScript
6
star
13

basic-redux-react-boilerplate

A very basic boilerplate to start a redux/react project.
JavaScript
6
star
14

draft-js-with-canvas-block

A little demo of how to render blocks that let you draw in a document
JavaScript
5
star
15

draft-js-persisting-data

Accompanying code for a tutorial on how to persist draft js content
JavaScript
5
star
16

slate-highlight-lesson

JavaScript
4
star
17

lexical-react-boilerplate

Boilerplate for lexical editor projects
TypeScript
4
star
18

static-proxy

WIP - a little server that serves static files and falls back to proxied content.
JavaScript
4
star
19

slate-in-react-native

Simple example of how slate can be used in a react native app
Java
3
star
20

react-snack

JavaScript
3
star
21

jkrsp

Blog
JavaScript
3
star
22

editable-js

JavaScript
3
star
23

html2svg

CoffeeScript
2
star
24

lexical-playground

A little playground for lexical-js πŸ₯³
TypeScript
2
star
25

react-berlin-lexical

react-berlin-lexical
TypeScript
2
star
26

Pollock

A canvas-based application which paints by itself.
CoffeeScript
2
star
27

0xnotes

TypeScript
2
star
28

terraform-external-data-source-examples

Examples of how to use terraform external data source
HCL
2
star
29

jest-puppeteer-github-action-tests

Automated browser tests with puppeteer, jest and github actions - for a react app.
TypeScript
2
star
30

slate-rich-text-lessons

egghead io lessons on slate js rich text editing
JavaScript
1
star
31

jamwithjam

done
JavaScript
1
star
32

lexical-workshop

TypeScript
1
star
33

basic-slate-lesson

JavaScript
1
star
34

react-rocket

CSS
1
star
35

websockets-step-functions

JavaScript
1
star
36

shaky

Configurable React UI library
JavaScript
1
star
37

draft-js-barebones-boilerplate

Barebones boilerplate for draft js
JavaScript
1
star
38

angular-line-graph

Simple svg directive for plotting data to a line
JavaScript
1
star
39

tiny-rx

A ligh-weight FRP implementation in JavaScript
JavaScript
1
star
40

spectrum-draft-js-inline-toolbar

JavaScript
1
star
41

angular-visualisation-directives

A collection of svg-based visualisation components
JavaScript
1
star
42

draft-js-flowtype-docs

Documentation of all types used in the draft-js repository
1
star
43

goodafternoon

My online playground, a tiny file-based blogging engine using express.js, the node.js framework
JavaScript
1
star
44

linda

JavaScript
1
star
45

React-Sketchbook

A very simple no configuration staging environment for react components
JavaScript
1
star
46

juliankrispel

1
star
47

lexical-workshop-playground

TypeScript
1
star
48

draft-js-diff-content-state

a little experiment
1
star
49

0xmarkmaking

JavaScript
1
star
50

testing-subgraph

TypeScript
1
star
51

basic-draftjs-lesson

Egghead lesson code for draft js basics
JavaScript
1
star
52

boxes

SASS/Compass Framework
Ruby
1
star
53

aws-states

Typescript library for dealing with AWS States Language and building Step Functions
TypeScript
1
star
54

csv-starling-freeagent

little utility to parse starling csvs into freeagent
JavaScript
1
star