2026-03-04 16:31:57 +03:00
|
|
|
# @hublib-web/content-suggestions
|
|
|
|
|
|
|
|
|
|
Cross-framework content text/title renderer with support for mentions, tags and links.
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
|
|
- Shared parser in `core` (`findAllEntities`, `findMentions`, `findTags`, `findLinks`).
|
|
|
|
|
- React UI components in `react`:
|
|
|
|
|
- `ContentText`
|
|
|
|
|
- `ContentTextWithSuggestions`
|
|
|
|
|
- `ContentTitleWithSuggestions`
|
2026-04-03 16:10:45 +03:00
|
|
|
- Angular UI components in `angular` (based on `@hublib-web/tach-typography/angular`):
|
|
|
|
|
- `ContentTextComponent`
|
|
|
|
|
- `ContentTextWithSuggestionsComponent`
|
|
|
|
|
- `ContentTitleWithSuggestionsComponent`
|
2026-03-04 16:31:57 +03:00
|
|
|
- Depends on `@hublib-web/tach-typography` for visual consistency.
|
|
|
|
|
- Business logic (API requests for mentions/tags) stays in consumer application.
|
|
|
|
|
|
|
|
|
|
## Install from Git (SSH tag)
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
yarn add "@hublib-web/content-suggestions@git+ssh://git@github.com/ORG/REPO.git#workspace=@hublib-web/content-suggestions&tag=content-suggestions-v0.1.0"
|
|
|
|
|
```
|
|
|
|
|
|
2026-04-03 16:10:45 +03:00
|
|
|
`@hublib-web/tach-typography@0.3.0` is a peer dependency.
|
2026-03-04 16:31:57 +03:00
|
|
|
|
|
|
|
|
## Install inside this monorepo
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
yarn add @hublib-web/content-suggestions
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Release this package
|
|
|
|
|
|
|
|
|
|
1. Bump `version` in `packages/content-suggestions/package.json`.
|
|
|
|
|
2. Build package artifacts:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
yarn workspace @hublib-web/content-suggestions build
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. Commit release files:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
git add packages/content-suggestions/package.json packages/content-suggestions/dist
|
|
|
|
|
git commit -m "release(content-suggestions): v0.1.0"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4. Create and push tag:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
git tag -a content-suggestions-v0.1.0 -m "@hublib-web/content-suggestions v0.1.0"
|
|
|
|
|
git push origin main --follow-tags
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Detailed docs:
|
|
|
|
|
|
|
|
|
|
- [Release policy](../../docs/release-policy.md)
|
|
|
|
|
- [Git installation](../../docs/git-installation.md)
|
|
|
|
|
|
|
|
|
|
## React usage
|
|
|
|
|
|
|
|
|
|
```tsx
|
|
|
|
|
import { ContentTextWithSuggestions } from "@hublib-web/content-suggestions/react";
|
|
|
|
|
|
|
|
|
|
<ContentTextWithSuggestions text={text} />;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
With app-specific mention business logic:
|
|
|
|
|
|
|
|
|
|
```tsx
|
|
|
|
|
<ContentTextWithSuggestions
|
|
|
|
|
text={text}
|
|
|
|
|
renderMention={(entity) => <MyMention entity={entity} />}
|
|
|
|
|
renderTag={(entity) => <MyTagLink entity={entity} />}
|
|
|
|
|
/>;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
By default, tags are rendered as plain styled text (not links).
|
|
|
|
|
|
|
|
|
|
## Angular usage
|
|
|
|
|
|
2026-04-03 16:10:45 +03:00
|
|
|
Standalone component usage:
|
2026-03-11 17:15:01 +03:00
|
|
|
|
2026-03-04 16:31:57 +03:00
|
|
|
```ts
|
2026-04-03 16:10:45 +03:00
|
|
|
import { Component } from "@angular/core";
|
|
|
|
|
import { ContentTextWithSuggestionsComponent } from "@hublib-web/content-suggestions/angular";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
standalone: true,
|
|
|
|
|
imports: [ContentTextWithSuggestionsComponent],
|
|
|
|
|
template: `
|
|
|
|
|
<content-text-with-suggestions
|
|
|
|
|
[text]="text"
|
|
|
|
|
[ellipsis]="{ count: 180, expandable: true }"
|
|
|
|
|
[onView]="onView"
|
|
|
|
|
/>
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
export class FeedPostComponent {
|
|
|
|
|
text = "@[John Doe](d290f1ee-6c54-4b01-90e6-d701748f0851) hello #tag";
|
|
|
|
|
|
|
|
|
|
onView = () => {
|
|
|
|
|
// analytics
|
|
|
|
|
};
|
|
|
|
|
}
|
2026-03-04 16:31:57 +03:00
|
|
|
```
|
|
|
|
|
|
2026-04-03 16:10:45 +03:00
|
|
|
Title variant with defaults (`weight: "bold"`, `ellipsis: { rows: 2 }`):
|
2026-03-11 17:15:01 +03:00
|
|
|
|
|
|
|
|
```ts
|
2026-04-03 16:10:45 +03:00
|
|
|
import { ContentTitleWithSuggestionsComponent } from "@hublib-web/content-suggestions/angular";
|
|
|
|
|
|
|
|
|
|
// template
|
|
|
|
|
// <content-title-with-suggestions [text]="title" />
|
2026-03-11 17:15:01 +03:00
|
|
|
```
|
|
|
|
|
|
2026-04-03 16:10:45 +03:00
|
|
|
Tokenization helper:
|
2026-03-11 17:15:01 +03:00
|
|
|
|
|
|
|
|
```ts
|
2026-04-03 16:10:45 +03:00
|
|
|
import { createAngularContentTokens } from "@hublib-web/content-suggestions/angular";
|
2026-03-11 17:15:01 +03:00
|
|
|
|
2026-04-03 16:10:45 +03:00
|
|
|
const tokens = createAngularContentTokens(text);
|
2026-03-11 17:15:01 +03:00
|
|
|
```
|
|
|
|
|
|
2026-03-04 16:31:57 +03:00
|
|
|
## Storybook (dev/design system)
|
|
|
|
|
|
|
|
|
|
Run from repository root:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
yarn workspace @hublib-web/content-suggestions storybook
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Build static Storybook:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
yarn workspace @hublib-web/content-suggestions storybook:build
|
|
|
|
|
```
|