Skip to content
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

Add htmlAttributes to UmbracoRichText and upgrade to Vitest 2 #6

Merged
merged 8 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
run: pnpm install
- name: Lint
run: pnpm biome ci .
- name: Install playwright
run: pnpx playwright install chromium
- name: Test
run: pnpm test
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ lib-cov
logs
node_modules
temp
__screenshots__
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install @charlietango/react-umbraco

### `<UmbracoRichText>`

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/github/charlie-tango/react-umbraco/tree/main/examples/UmbracoRichText?file=src/RichText.tsx)
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/github/charlie-tango/react-umbraco/tree/main?file=examples/UmbracoRichText/src/RichText.tsx)

Takes the rich text property from the Umbraco Content Delivery API and renders
it with React.
Expand All @@ -28,6 +28,10 @@ it with React.
- `renderBlock`: Render a specific block type.
- `renderNode`: Overwrite the default rendering of a node. Return `undefined` to
render the default node. Return `null` to skip rendering the node.
- `htmlAttributes`: Default attributes to set on the defined HTML elements.
These will be used, unless the element already has the attribute set. The only
exception is the `className` attribute, which will be merged with the default
value.

When passing the `renderBlock` and `renderNode` props, consider making them
static functions (move them outside the consuming component) to avoid
Expand Down Expand Up @@ -74,6 +78,7 @@ function RichText({ data }) {
element={data.richText}
renderNode={renderNode}
renderBlock={renderBlock}
htmlAttributes={{ p: "mb-4" }}
/>
);
}
Expand Down
18 changes: 0 additions & 18 deletions examples/UmbracoRichText/.eslintrc.cjs

This file was deleted.

39 changes: 0 additions & 39 deletions examples/UmbracoRichText/README.md

This file was deleted.

Loading