MCPcopy Index your code
hub / github.com/edg2s/rangefix

github.com/edg2s/rangefix @0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.0 ↗ · + Follow
6 symbols 12 edges 4 files 1 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Workaround for browser bugs in Range.prototype.getClientRects and Range.prototype.getBoundingClientRect.

In particular:

  • Chrome <= 54: Selections spanning multiple nodes return rectangles for all the parents of the endContainer. See https://code.google.com/p/chromium/issues/detail?id=324437.
  • Chrome 55: Images get no rectangle when they are wrapped in a node and you select across them.
  • Safari: Similar to the Chrome <= 54 bug, but only triggered near the edge of a block node, or programmatically near an inline node.
  • Firefox: Similar to the Chrome <= 54 bug, but only triggered near the edge of a inline node
  • Chrome: Selection across a space which spans two lines results in a bounding rectangle which doesn't cover all the individual rectangles.
  • Firefox: Selections across a space which spans two lines, and text on the next line results in a bounding rectangle which doesn't cover all the individual rectangles.

There are no known issues in Edge. When no issues are detected the library will fall through to native behaviour.

Install

$ npm install rangefix

Usage

CommonJS

var RangeFix = require( 'rangefix' );

AMD

define( [ 'rangefix' ], function ( Rangefix ) {
    // ...
} );

Browser global

<script src="https://github.com/edg2s/rangefix/raw/0.3.0/path/to/rangefix.js"></script>

API

Replace instances of Range.prototype.getClientRects/getBoundingClientRect with RangeFix.getClientRects/getBoundingClientRect:

var range = document.getSelection().getRangeAt( 0 );

// Before
var rects = range.getClientRects();
var boundingRect = range.getBoundingClientRect();

// After
var rects = RangeFix.getClientRects( range );
var boundingRect = RangeFix.getBoundingClientRect( range );

Demo

http://edg2s.github.io/rangefix/

Core symbols most depended-on inside this repo

getCssProps
called by 4
demo/demo.js
batchPush
called by 3
src/rangefix.js
rectExceedsBoundingRect
called by 2
src/rangefix.js
updateMirrors
called by 2
demo/demo.js
indexOf
called by 1
src/rangefix.js
render
called by 1
demo/demo.js

Shape

Function 6

Languages

TypeScript100%

Modules by API surface

src/rangefix.js3 symbols
demo/demo.js3 symbols

For agents

$ claude mcp add rangefix \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page