Giter VIP home page Giter VIP logo

Comments (11)

Maboroshy avatar Maboroshy commented on July 17, 2024 1

Tags are exposed to scripting . There's a property to get the parent tag object and another one to get tag's name.

from scripts.

r00tr4v3n avatar r00tr4v3n commented on July 17, 2024

I was digging around in the script and found this:
[23:17:40] [warning] file:///[...]/epsilon-notes-tags.qml:100: ReferenceError: tagLineStartIndex is not defined
This is probably the reason why no additional tags can be added.
I don't get why tagLineMatch is null if it parses fine for the other iterations of the code?

from scripts.

Maboroshy avatar Maboroshy commented on July 17, 2024

I saw this too while testing your issue. Don't remember this error last time I've updated the script. I'll fix it.

from scripts.

r00tr4v3n avatar r00tr4v3n commented on July 17, 2024

I think tagLineStartIndex and tagLineEndIndex should be declared for the function and not locally.

                    const tagLineStartIndex = tagLineMatch.index
                    const tagLineEndIndex = tagLineStartIndex + tagLineMatch[0].length

epsilon-notes-tags.qml#L62

This fixes the error for me, I can now add and remove yaml tags via the tag panel (and doubleclick).

from scripts.

r00tr4v3n avatar r00tr4v3n commented on July 17, 2024

As for the nested tags, there would be a lookup function for parent tags needed. Is there an API call besides script.searchTagsByName("game"); and if not, could you add it? @pbek

from scripts.

r00tr4v3n avatar r00tr4v3n commented on July 17, 2024

How are you guys debugging scripts? Is there a way to get code completion and break points/references in the QtCreator?
I get the feeling that this nested tags feature will get pretty messy if I have to iterate recursively over an entire tag list to get all parents' names by id.

A little exercise:

        var tagList = []
        note.tags.forEach(function(tag, index, array) {
            script.log(tag)
            if (tag.parentId !== 0)
                tagList.push(tag)
            })

Why does this throw a TypeError, isn't QQmlListProperty a list/array?

from scripts.

Maboroshy avatar Maboroshy commented on July 17, 2024

I use good old script.log all over the place. It will be messy and if you want it to be pulled into original script nested tags should be optional.

As for QQmlListProperty, looks like it can't do forEach. Maybe @pbek knows better.

from scripts.

Maboroshy avatar Maboroshy commented on July 17, 2024

Try a classic loop like:

var i
for (i = 0; i < note.tags.length; i++) {
    script.log(note.tags[i])
}

from scripts.

r00tr4v3n avatar r00tr4v3n commented on July 17, 2024

Try a classic loop like:

Will try, thank you.

I use good old script.log all over the place. It will be messy and if you want it to be pulled into original script nested tags should be optional.

That's what I was afraid of, logs it it. I don't think nested tags are within capabilities yet, I'll try something smaller first. Do you have an idea how to handle the parent search elegantly?

from scripts.

pbek avatar pbek commented on July 17, 2024

As for the nested tags, there would be a lookup function for parent tags needed. Is there an API call besides script.searchTagsByName("game"); and if not, could you add it?

Could you please make QOwnNotes feature requests and be more specific of what you need.

from scripts.

Maboroshy avatar Maboroshy commented on July 17, 2024

Do you have an idea how to handle the parent search elegantly?

I'd go with a recursive function.

from scripts.

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.