Skip to content

Commit

Permalink
update readme, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
pokornyd committed Aug 19, 2024
1 parent 4259f7c commit 64fc52e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ Besides default blocks for common elements, Portable text supports custom blocks

#### Component/linked item

https://github.com/kontent-ai/rich-text-resolver-js/blob/14dcf88e5cb5233b1ff529b350341dfac79a888b/showcase/showcase.ts#L3-L10
https://github.com/kontent-ai/rich-text-resolver-js/blob/6fe68490a32bb304d141cff741fb7e57001550eb/showcase/showcase.ts#L3-L11

#### Image

https://github.com/kontent-ai/rich-text-resolver-js/blob/14dcf88e5cb5233b1ff529b350341dfac79a888b/showcase/showcase.ts#L12-L20
https://github.com/kontent-ai/rich-text-resolver-js/blob/6fe68490a32bb304d141cff741fb7e57001550eb/showcase/showcase.ts#L13-L22

> 💡 For image resolution, you may use `resolveImage` helper function. You can provide it either with a custom resolution method or use provided default implementations for HTML and Vue, `toHTMLImageDefault` and `toVueImageDefault` respectively.
#### Item link

https://github.com/kontent-ai/rich-text-resolver-js/blob/14dcf88e5cb5233b1ff529b350341dfac79a888b/showcase/showcase.ts#L22-L29
https://github.com/kontent-ai/rich-text-resolver-js/blob/6fe68490a32bb304d141cff741fb7e57001550eb/showcase/showcase.ts#L24-L31

#### Table

https://github.com/kontent-ai/rich-text-resolver-js/blob/14dcf88e5cb5233b1ff529b350341dfac79a888b/showcase/showcase.ts#L31-L58
https://github.com/kontent-ai/rich-text-resolver-js/blob/6fe68490a32bb304d141cff741fb7e57001550eb/showcase/showcase.ts#L33-L59

> 💡 For table resolution, you may use `resolveTable` helper function. You can provide it either with a custom resolution method or use default implementation from a resolution package of your choice (such as `toHTML` or `toPlainText`)
Expand Down Expand Up @@ -267,6 +267,25 @@ const components: PortableTextComponents = {
</template>
```
### MAPI transformation
`toManagementApiFormat` is a custom transformation method built upon `toHTML` package, allowing you to restore portable text previously created from management API rich text back into MAPI supported format.
```ts
const richTextContent =
`<p>Here is an <a data-item-id="12345"><strong>internal link</strong></a> in some text.</p>`;

const tree = nodeParse(richTextContent);
const portableText = transformToPortableText(tree);

const validManagementApiFormat = toManagementApiFormat(portableText);
```
> [!WARNING]
> MAPI transformation logic expects Portable Text that had been previously created from management API rich text and performs only minimal validation.
>
> Transformation from other formats (such as delivery API) is not supported unless the blocks are manually adjusted to be MAPI compatible prior to running the method.
[last-commit]: https://img.shields.io/github/last-commit/kontent-ai/rich-text-resolver-js?style=for-the-badge
[contributors-shield]: https://img.shields.io/github/contributors/kontent-ai/rich-text-resolver-js?style=for-the-badge
[contributors-url]: https://github.com/kontent-ai/rich-text-resolver-js/graphs/contributors
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kontent-ai/rich-text-resolver",
"version": "1.1.3",
"version": "1.2.0",
"private": false,
"description": "Kontent.ai rich text element resolver and PortableText transformer for JavaScript and TypeScript",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ const mergeSpansAndMarks: MergePortableTextItemsFunction = (itemsToMerge) => {
handleLinks(mergedItems, item);
break;
case "mark":
/**
* push a tuple filled marks, sized to match the number of affected child text nodes
*/
markSets.push(Array(item.childCount).fill(item.value));
break;
case "span":
Expand Down

0 comments on commit 64fc52e

Please sign in to comment.