Skip to content

Conversation

@pokornyd
Copy link
Member

@pokornyd pokornyd commented Nov 4, 2024

Motivation

  • added resolution capabilities for non-rich-text-native HTML tags
  • reworked transformation logic
    • fixed an issue where styles weren't correctly applied to styled text with line breaks
  • updated several naming conventions to better match Kontent.ai counterparts
  • improved typing

Checklist

  • Code follows coding conventions held in this repo
  • Automated tests have been added
  • Tests are passing
  • Docs have been updated (if applicable)
  • Temporary settings (e.g. variables used during development and testing) have been reverted to defaults

How to test

If manual testing is required, what are the steps?

@pokornyd pokornyd force-pushed the vNext branch 5 times, most recently from 3ff3952 to fdf4711 Compare November 17, 2024 12:46
@pokornyd pokornyd force-pushed the vNext branch 3 times, most recently from 4b976fc to bb83273 Compare November 20, 2024 02:30
@pokornyd pokornyd marked this pull request as ready for review January 6, 2025 21:28
@pokornyd pokornyd requested review from a team and IvanKiral as code owners January 6, 2025 21:28
@pokornyd pokornyd self-assigned this Jan 7, 2025
@pokornyd pokornyd force-pushed the vNext branch 2 times, most recently from 7f66ffa to 97adf07 Compare January 13, 2025 18:56
@codecov
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 86.56716% with 36 lines in your changes missing coverage. Please review.

Project coverage is 88.80%. Comparing base (850bd38) to head (445b7b4).
Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/common-utils.ts 61.70% 18 Missing ⚠️
...able-text-transformer/portable-text-transformer.ts 89.71% 11 Missing ⚠️
.../transformers/html-transformer/html-transformer.ts 93.54% 2 Missing ⚠️
src/utils/resolution/html.ts 86.66% 2 Missing ⚠️
src/parser/index.ts 85.71% 1 Missing ⚠️
src/utils/resolution/mapi.ts 83.33% 1 Missing ⚠️
src/utils/resolution/react.tsx 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
- Coverage   94.79%   88.80%   -5.99%     
==========================================
  Files          19       22       +3     
  Lines         365      420      +55     
  Branches       68       85      +17     
==========================================
+ Hits          346      373      +27     
- Misses         19       47      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

_type: "componentOrItem",
_key: "guid",
component: {
_ref: "linkedItemOrComponentCodename",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pokornyd , Would it be possible to change the _ref and _key in various objects with the expected value? I.e. in this case you assign a codename, but when using this I have no way of knowing if it's a codename/id or something else entirely.

If these properties are necessary for some reason and can't be renamed, I think it would be worth adding new custom properties that will represent the ID/codename appropriately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @Enngage. this had already been done. the underlying Reference type now also contains a referenceType string literal, with value of codename, external-id or id, informing you of the nature of the value stored in _ref.

the showcase is updated to reflect that, but the readme embed points to main branch version of it. should get sorted after the merge :)

types: {
image: ({ value }: PortableTextComponentProps<PortableTextImage>) => resolveImage(value, h, toVueImageDefault),
image: ({ value }: PortableTextComponentProps<PortableTextImage>) => resolveImage(value, h),
table: ({ value }: PortableTextComponentProps<PortableTextTable>) => resolveTable(value, h, toPlainText),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pokornyd not sure if this was changed, but when testing it I noticed that all properties under types were required - meaning you had to provide some sort of implementation even if you only needed to provide a resolver for image. Can these props be made optional instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the helper types (PortableTextHtmlResolvers, PortableTextReactResolvers) are both set to be partial. I didn't create helper type for Vue, but PortableTextComponents["types"] appears to be partial by default

@pokornyd pokornyd requested a review from IvanKiral January 20, 2025 10:04
(child: T) => traversePortableText(child, callback),
);
}
export const traversePortableText = <
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: formatting of generic can be onelined

import { DomHtmlNode, DomNode } from "../../parser/parser-models.js";

export type NodeToHtml<TContext = unknown> = (
node: DomHtmlNode<any>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be node: DomHtmlNode<unknown>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. changed

@pokornyd pokornyd requested a review from IvanKiral January 20, 2025 18:44
@pokornyd pokornyd merged commit fb829ce into main Jan 21, 2025
1 check passed
@pokornyd pokornyd deleted the vNext branch January 21, 2025 09:13
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.

4 participants