Skip to content

chore: add style exports for all stylesheets #1657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025

Conversation

RobinClowers
Copy link
Contributor

Adds style exports for all stylesheets, so they can be imported by postcss / tailwind.

When upgrading to tailwind 4, we ran into an issue where our tailwind utility classes suddenly couldn't override blocknote styles anymore. This turns out to be related to css layers. It's easy to solve by importing the styles in css (where we can assign them a layer), but unfortunately it's not possible without these style exports.

See https://github.com/postcss/postcss-import for more details.

Copy link

vercel bot commented May 2, 2025

@RobinClowers is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@YousefED YousefED requested a review from nperez0111 May 5, 2025 07:09
@nperez0111
Copy link
Contributor

Hi @RobinClowers I missed this one.

Could you expand a bit on why you need it to be part of the package.json#exports it wasn't obvious to me from the postcss-import docs.

In my understanding, you should be able to point to the file you need directly as a relative path, are you maybe trying to have it be a bit more pleasant by allowing it to just be @import 'module-name';? If so, it isn't obvious to me that ./styles would do that by default or anything

@RobinClowers
Copy link
Contributor Author

@nperez0111 no problem, thanks for getting back to me.

Specifically this line from the postcss-import docs is relevant:

When importing a module, it will look for index.css or file referenced in package.json in the style or main fields.

I want to be able to do this:

@import "@blocknote/core/style.css" layer(components);

Which scopes the styles in the components layer, allowing tailwind utilities to override them (because of the layer order, the utility layer has a higher precedence than components).

To your point, I suppose I could import directly from the path, e.g. node_modules/@blocknote/core/dist/style.css, but that's more brittle.

Is there some downside to exposing these exports?

@nperez0111
Copy link
Contributor

Ah, that is what I missed. Alright, I'm on board with this change.

I know this is minor but, could move the style export down? package.json#exports are actually order-dependent so I don't want this to cause issues for others. I'll get the workflow running so you can test this in your project with the pkg.pr.new install. (may be worth rebasing to the current main if you want the latest version)

Copy link

pkg-pr-new bot commented May 9, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@1657

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@1657

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1657

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@1657

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@1657

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@1657

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@1657

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@1657

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@1657

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@1657

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@1657

commit: 497e0db

@RobinClowers
Copy link
Contributor Author

Sure thing, rebased on the latest main and moved the exports to the end.

@RobinClowers
Copy link
Contributor Author

When I tried to install the PR package, I ran into this:

$ bun i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1657
bun add v1.2.11 (cb6abd21)
error: Package "@blocknote/core@https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1657" has a dependency loop
  Resolution: "@blocknote/[email protected]"
  Dependency: "@blocknote/core@https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1657"
error: An internal error occurred (DependencyLoop)

Not sure if this is something specific to bun, I've never used pgk.pr.new.

@nperez0111
Copy link
Contributor

Yea, with the pkg.pr.new, since the packages depend on each other, you may need to force the versions to resolve to the pkg.pr.new versions instead using an override.

@RobinClowers
Copy link
Contributor Author

@nperez0111 I was able to test this and it worked for me, it's good to merge from my perspective.

@nperez0111 nperez0111 merged commit 163f8c1 into TypeCellOS:main May 15, 2025
0 of 2 checks passed
@nperez0111
Copy link
Contributor

Thanks for the contribution @RobinClowers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants