Giter Site home page Giter Site logo

Comments (5)

ZhijieZhang avatar ZhijieZhang commented on August 24, 2024

We tested this API with some cases and it seems working. Do you minding providing a code snippet so that we could take a look into? :)

from webviewer-ui.

sabieber avatar sabieber commented on August 24, 2024

It seems to only work when the user switches to another leftpanel tab and then back to the notes.
What we try to accomplish is a toggle inside of the notes panels where the user can toggle between two different sortings.

This is the sort strategy:

var noFilter = function (notes) {
    return notes;
}

var filterRevised = function (notes) {
    return notes.filter(function (note) {
        return !note.oxomiRevised && note.getContents();
    });
}

var oxomiSortStrategy = {
    getSortedNotes: function (notes) {
        return oxomiSortStrategy.filter(notes).sort(function (a, b) {
            // Sort by reading order (top to bottom left to right)
            var verticalDiff = a.getY() - b.getY();
            if (verticalDiff !== 0) {
                return verticalDiff;
            }
            return a.getX() - b.getX();
        });
    },

    shouldRenderSeperator: function (previous, current) {
        return current.PageNumber !== previous.PageNumber;
    },

    getSeperatorContent: function (previous, current) {
        return current.PageNumber;
    },

    filter: noFilter
};

And this is where we switch between the filters and reapply the sort strategy:

Config.showAllAnnotations = function () {
    oxomiSortStrategy.filter = noFilter;
    readerControl.setNotesPanelSort(oxomiSortStrategy);
}

Config.showOpenAnnotations = function () {
    oxomiSortStrategy.filter = filterRevised;
    readerControl.setNotesPanelSort(oxomiSortStrategy);
}

This is the current workaround:

Config.showAllAnnotations = function () {
    oxomiSortStrategy.filter = noFilter;
    readerControl.setSortNotesBy('position');
    readerControl.setNotesPanelSort(oxomiSortStrategy);
}

from webviewer-ui.

sabieber avatar sabieber commented on August 24, 2024

After inspecting the code I fixed it by changing it to two separate sort strategies with names, registering them and switching by calling setSortNotesBy and their name.

The issue I see here is that documentation for setNotesPanelSort and the sort object (with methods getSortedNotes, shouldRenderSeperator, getSeperatorContent and the name field) is missing completely here: https://www.pdftron.com/documentation/web/guides/ui/apis

from webviewer-ui.

ZhijieZhang avatar ZhijieZhang commented on August 24, 2024

Good to hear you fixed it! We didn't mean to make this API public yet, that's why the documentation is missing in the APIs section. We were planning to squash new APIs and make them public with proper documentation in the next minor release. Sorry for the confusion, we made a mistake as we shouldn't merge this new API into master until the next release. We will be careful next time! Please note that we may also change the name of this API. We will let you know when we changed it

from webviewer-ui.

sabieber avatar sabieber commented on August 24, 2024

Thanks for the info and the heads up 👍

from webviewer-ui.

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.