Contents of text-fragments-ts
Latest commit: Update to spec version of 25 October 2020 3 years ago

src 3 years ago
.gitignore 4 years ago
Readme.md 4 years ago
demo.html 4 years ago
package-lock.json 4 years ago
package.json 4 years ago
tsconfig.json 4 years ago

Readme.md

Text Fragments — TypeScript implementation

This is an implementation of (most of) the WICG’s Text Fragments draft specification: https://wicg.github.io/scroll-to-text-fragment/.

It implements the spec line by line, in order to help serve as a reference implementation and to help test the specification. No attempt is made to e.g. increase efficiency.

A polyfill is provided to use text fragments in browsers and other HTML viewers that do not support this feature natively.

Try it out in the playground!

Status

Although intended mainly to help test and improve the specification, it works and could be used in practice. However, as the spec is still a draft, expect this implementation to change too. Note that some corners of the spec are not yet fully implemented (search for TODO comments in the source code).

Note that no effort has been made to make this run in environments that do not support ES2017.

Install

To use this implementation in your own code:

npm install "git+https://code.treora.com/gerben/text-fragments-ts.git#semver:^0.1.0"

…or equivalent.

Every definition that has been implemented is exported to allow creating compatibility tests, your own polyfill, annotation tool, or other usage (please tell about your use case!). For the precise API, please look at the exports in the source code (src/index.ts), and perhaps at how the polyfill (src/polyfill.ts) uses them.

To use the polyfill, include the package’s lib/polyfill.js into a web page (or browser extension, …):

<script src="path/to/text-fragments-ts/lib/polyfill.js" type="module"></script>