Code Monkey home page Code Monkey logo

Comments (7)

TfTHacker avatar TfTHacker commented on August 23, 2024

This is a good issue. Live preview doesn't capture everything, but I am trying. Can you give me some namespace examples?

I recently added support for complex page names (page names within page names): [[This is a page [[with embedded]] page]]

from workbench.

alexchiri avatar alexchiri commented on August 23, 2024

I prepared here an example and steps to reproduce: https://roamresearch.com/#/app/alexchiri_public/page/08-26-2020

It actually breaks only when the namespaces are collapsed using Ctrl-C Ctrl-L, which is how I keep them always in my Roam graph. Use the link above to try to reproduce it, I was able to do so in an incognito window just now. Hope it helps and let me know if you need more info.

And thanks for building Roam42, it's really great to see all the nice tools the community builds!

from workbench.

TfTHacker avatar TfTHacker commented on August 23, 2024

Alex good find. Also have a similar problem with complex links [[sample page [[with embedded page]] ]] if the bracket viw is turned off CTRL C, CTRL B

This problem is a bit more complex to solve. I at some point will rewrite live preview and make it more robust. For now, it will be a while before I can fix this.

I really appreciate your time thought to document the problem. I am copying your sample here for future reference:

  • Steps to reproduce issue:
    • Enable Roam 42 here: [[Roam42]]
    • Press Ctrl-C Ctrl-L once so the Books namespace collapses to the first letter only: [[Books/Interesting book]] becomes B/Interesting book
    • Enable Live Preview
    • Hover over this link [[Books/Interesting book]] and look at the console in developer tools

from workbench.

alexchiri avatar alexchiri commented on August 23, 2024

No worries, not a big issue. I now know that it works if namespaces are not collapsed.

from workbench.

c3founder avatar c3founder commented on August 23, 2024

My issue with non-collapsed namespaces (e.g., [[B1]] instead of [[Book/B1]]) is that I have different styles (color, etc.) for each namespace, and for the none-collapsed one, [[Book/B1]], there is no namespace tag in the HTML that my CSS can select and apply the desired style.

So expanding namespaces is not an ideal solution for me. Here is my quick fix: In the live preview JS code there is a mouseover event listener where I added a few lines of code (in bold):

document.addEventListener('mouseover', (e) => {
const target = e.target;
const isPageRef = target.classList.contains('rm-page-ref');
const isPageRefTag = target.classList.contains('rm-page-ref-tag');
const isPageRefNameSpace = target.classList.contains('rm-page-ref-namespace-color');
// remove '#' for page tags
if(isPageRefTag){
var text = target.innerText.slice(1)
} else if(isPageRefNameSpace) {
var text = target.parentElement.getAttribute('data-link-title')
}
else {
var text = target.innerText;
}
This has fixed my problem and loads the preview for collapsed namespaces.

from workbench.

TfTHacker avatar TfTHacker commented on August 23, 2024

Thanks for this code snippet. I added it to the code and will be a part of the next release. If you want to test it now, pop into the #roam42 slack channel. There we have info about how to access the test version.

from workbench.

c3founder avatar c3founder commented on August 23, 2024

from workbench.

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.