Giter Site home page Giter Site logo

Comments (3)

pablojan avatar pablojan commented on June 11, 2024

Hi, thanks!

In that version of swell you can't control manually the annotations rendering diffs. So in order to turn on/off them you must call methods showDiffHighlight()' and hideDiffHighlight()` on the text node itself.

from swellrt.

emcodemall avatar emcodemall commented on June 11, 2024

Thanks for the quick answer pablo.
to give something back to the opensource community, here my fix. i was able to apply your suggestion by using this javascript code. The problem is that i could not figure out how to select the "text node itself"
so i just walk through all childs of a div of the page. call this function after the editor was attached to a dom object.

  function disableEditorAnnotations(){
    //workaround missing api option to be in control of marked or striked trough text when someone else edits it
    var objs = []; // we'll store the object references in this array
    function walkTheObject( obj ) {
        var keys = Object.keys( obj ); // get all own property names of the object
        var counter = 0;
        keys.forEach( function ( key ) {
            var value = obj[ key ]; // get property value
            counter++
            // if the property value is an object...
            if ( value && typeof value === 'object' ) { 

                // if we don't have this reference...
                if ( objs.indexOf( value ) < 0 ) {
                    objs.push( value );
                    //objs.push( value ); // store the reference
                    walkTheObject( value ); // traverse all its own properties
                } 

            }
        });
    }


    walkTheObject(document.getElementsByTagName("div"));

    for (i=0; i<objs.length;i++){
        try {
            //console.log(objs[i])
            if (objs[i].stopShowDiffs){
                objs[i].stopShowDiffs();
            }
        }
        catch(err) {
           //console.log(err);
        }
    }
  
  }

from swellrt.

emcodemall avatar emcodemall commented on June 11, 2024

stopShowDiffs is only available in the dev build. also i still did not get out what you mean by "the text node".
Any clue would be very welcome!

from swellrt.

Related Issues (20)

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.