Coder Social home page Coder Social logo

neisbut / textannotator Goto Github PK

View Code? Open in Web Editor NEW
102.0 102.0 18.0 386 KB

Small and simple JS tool for making powerful underline, highlight and strike text annotations

License: MIT License

JavaScript 78.65% CSS 1.49% HTML 14.61% Python 5.24%

textannotator's People

Contributors

neisbut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

textannotator's Issues

Based on your code, I made a simplified version

So I can easily change the css style of annotated text.

About 20 lines of code.

// usage:
// 1. mouse select text range to highlight
// 2. click on highlighted range to remove highlight
//
(function () {
    // rangy.init(); // init() by default?

    // highlight selected text range
    $('#yuedu').mouseup(function(e) {
        rangy.getSelection();
        rangy.createCssClassApplier('annotation').applyToSelection(); 
    });

    // remove hightlight
    $('#yuedu').delegate("span", "click", function (e) {
        var text = $(this).text();
        $(this).replaceWith(text);
    });
    // prevent nested hightlight
    $('#yuedu').delegate("span", "mousedown", function (e) {
        var text = $(this).text();
        $(this).replaceWith(text);
    });
})();

demo repo at: https://github.com/404pnf/textAnnotation-mimic-kindle-effect

Thank you again for showing me how to do this by your code!

How to delete a single highlight?

I see a function, that's remove every highlight element.

/**
 * Removes annotation from element
 * @export
 */
tvs.ElementAnnoationInfo.prototype.remove = function() {
    goog.array.forEach(this.annotationElements, goog.dom.removeNode);
    delete this.annotetedElement[this.elPropName];
    this.annotetedElement = null;
};

Can I remove a single one by select / hover over an highlighted element and click on a "delete" tooltip?

Thank you!

How to store highlights

Can you suggest a good way to save these highlights to that the user would see them everytime they come back to that page?

Annotation positioning issues on scroll.

When I used the library to implement annotation on HTML and if I put those annotations under an element with scroll. The annotations couldn't retain their position relative to the element. I am attaching a screenshot of the issues I found .
Compare both images before and after scroll
image
image

Why do the position:absolute divs exist?

I found this library after reading this article:
http://www.toptal.com/javascript/annotating-texts-on-the-web-using-svg

It seems that the text annotations are implemented via divs with position: absolute that are appended to the body. Those divs have a repeating SVG for a background image.
I tried it, and it was possible to simply set the background-image property of the

The only downside I see is that using this it's only possible to have a single effect on a piece of text. However, this trivially fixes any resizing and text-movement issues.

What is the rationale behind having position:absolute overlays versus simply setting the background of the s?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.