Skip to content

Commit

Permalink
Merge branch 'master' of github.com:prismicio/prismic-client into lh/…
Browse files Browse the repository at this point in the history
…update-eslint-config
  • Loading branch information
lihbr committed Jul 23, 2024
2 parents 2f8de18 + 3bcf410 commit a4e90cf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [7.7.3](https://github.com/prismicio/prismic-client/compare/v7.7.2...v7.7.3) (2024-07-23)


### Bug Fixes

* ignore trimmed empty spans ([6d1ce03](https://github.com/prismicio/prismic-client/commit/6d1ce035f7f5b3c112c3f00460190fdbd98e3543))

### [7.7.2](https://github.com/prismicio/prismic-client/compare/v7.7.1...v7.7.2) (2024-07-23)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prismicio/client",
"version": "7.7.2",
"version": "7.7.3",
"description": "The official JavaScript + TypeScript client library for Prismic",
"keywords": [
"typescript",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/hastToRichText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const hastToRichText = (
case RichTextNodeType.em:
case RichTextNodeType.label:
case RichTextNodeType.hyperlink: {
const length = toString(node).length
const length = toString(node).trimEnd().length

try {
builder.appendSpan(shorthandOrNode, length)
Expand Down Expand Up @@ -238,7 +238,7 @@ export const hastToRichText = (
case RichTextNodeType.label:
case RichTextNodeType.hyperlink: {
const span = serializeSpan(node, match)
const length = toString(node).length
const length = toString(node).trimEnd().length

try {
builder.appendSpan(span, length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ exports[`transforms HTML to rich text > spans > empty spans 1`] = `
{
"direction": "ltr",
"spans": [],
"text": "lorem ipsum dolor sit amet",
"text": "lorem ipsum dolorsit amet",
"type": "paragraph",
},
]
Expand Down
4 changes: 3 additions & 1 deletion test/helpers-unstable_htmlAsRichText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ describe("transforms HTML to rich text", () => {
})

testHTMLAsRichTextHelper("empty spans", {
input: /* html */ `<p>lorem <strong></strong>ipsum dolor sit amet</p>`,
// It's normal for `dolor` and `sit` to be concatenated here.
// That's how the browser would render it.
input: /* html */ `<p>lorem <strong></strong>ipsum dolor<em> </em>sit amet</p>`,
expectHTMLToMatchInputExactly: false,
})

Expand Down

0 comments on commit a4e90cf

Please sign in to comment.