Git Product home page Git Product logo

roamjs-components's People

Contributors

cristiansofronie avatar dvargas92495 avatar mdroidian avatar

Stargazers

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

Watchers

 avatar  avatar

roamjs-components's Issues

Upgrade to idb 7

idb is a peer dependency for this project, but linked to version 6.0.0. Version 7 has been stable for a year now, and version 7.1.1 was just released yesterday. This would allow other extensions to more easily use the most recent idb. I currently am having to do npm install --force to get roamjs-components and idb 7.

Happy to try to make a pr for this, but I didn't see any guidelines for developing or running tests, so figured best to open this. Let me know!

ComponentContainer unmounts if parent added to tree

EDIT: more specifically: when a preceding sibling is added to an ancestor block

Example
https://www.loom.com/share/af9dce45fe654b96a56aacb9ee5d60d0

It looks like the cause is n.contains(p) from renderWithUnmount

const parentRemoved = ms
      .flatMap((m) => Array.from(m.removedNodes))
      .some((n) => n === p || n.contains(p));
    if (parentRemoved) {
      unmount(observer);
    }

@dvargas92495 , what case is n.contains(p) solving for that n === p doesn't?

EDIT: further testing showed that n.contains(p) is used when a block is being edited or folded

Date NLP "start of week" and "end of week" don't follow User setting of "First day of week"

src/date/parseNlpDate.ts call startOfWeek & endOfWeek without the optional parameter weekStartsOn.

Thus the week start defaults to Sunday sadly which is not the convention followed for much of the world.

Roam stores the setting as can be seen in the Javascript console:
roamAlphaAPI.q('[:find ?settings :where [_ :user/settings ?settings]]')?.[0]?.[0]?.["first-day-of-week"]

I suppose it's best to take the user account setting within that component rather than complicating the extensions that use the library. Though it then makes date parsing code user preferences aware which makes it complex..hmmmm. Thoughts?

Fine-grained tokens do not work with GitHub Rest Pull API

tl:dr - fine-grained tokens result in 403, using classic token instead


When creating a PR via

const url = await axios
.post(
`https://api.github.com/repos/Roam-Research/roam-depot/pulls`,
{
head: `${owner}:${branch}`,
base: "main",
title,
},
opts()
)
.then((r) => r.data.html_url)
.catch((e) => Promise.reject(e.response.data || e.message));

Where
owner = RoamJS
branch = query-builder

We have been continually getting the following error (latest run with error)

{
  message: 'Resource not accessible by personal access token',
  documentation_url: 'https://docs.github.com/rest/pulls/pulls#create-a-pull-request',
  status: '403'
}

According to the GitHub REST API docs, fine-grained tokens only require "Pull request" write access for this

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Pull requests" repository permissions (write)

Yet, even with a Fine-grained token with full read-write to repo/org and access to all repos, we could continually get a 403 error.

image
Note: this was also tried with multiple users as the Resource owner
image
image

I have also replicated this using a VSCode Extension, Thunder Client, with updated headers as per GitHub docs

image

Others have also reported this issue:
https://github.com/orgs/community/discussions/106661
https://github.com/orgs/community/discussions/123362

Build Error

@dvargas92495 Build Error. Issue with PullBlock / ActionParams type mismatch.

Error in mockRoamEnvironment.ts

createBlock: async (action) => {
      if (!action.block) throw new Error(`block field is required`);
      if (!action.location) throw new Error(`location field is required`);
      const parent = graph.uids[action.location["parent-uid"]];
      if (!parent)
        throw new Error(
          `Could not find parent by uid: ${action.location["parent-uid"]}`
        );
      const parentBlock = graph.state[parent];
      const id = getDbId();
      const block = {
        ":block/string": action.block.string,
        ":block/uid":
          action.block.uid || window.roamAlphaAPI.util.generateUID(),
        ":block/parents": ([{ ":db/id": parent }] as PullBlock[]).concat(
          parentBlock[":block/parents"] || []
        ),
        ":db/id": id,
        ":block/order": action.location.order,
      };
      graph.uids[block[":block/uid"]] = id;
      parentBlock[":block/children"] = (
        parentBlock[":block/children"] || []
      ).concat({ ":db/id": id });
      graph.state[id] = block;  // ERROR HERE - Types of property '":block/order"' are incompatible.
    },

I tried just adding "last" to Pullblock, but that gave a bunch of other errors, for instance in getBasicTreeByParentUid

const sortBasicNodes = (c: PullBlock[]): RoamBasicNode[] =>
  c
    .sort((a, b) => (a[":block/order"] || 0) - (b[":block/order"] || 0))
    .map((node) => ({
      children: sortBasicNodes(node[":block/children"] || []),
      uid: node[":block/uid"] || "",
      text: node[":block/string"] || "",
    }));

Which makes sense. I image PullBlock doesn't return "last".

What is the relationship between ActionParams and PullBlock?
Do we create a separate CreateBlock type?

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.