@iyulab/chat-components 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/components/blocks/UMarkedBlock.js +1 -1
- package/dist/components/blocks/URefBlock.js +1 -0
- package/dist/components/references/URefCard.d.ts +8 -0
- package/dist/components/references/URefCard.js +15 -0
- package/dist/components/references/URefCard.styles.js +17 -0
- package/dist/index.js +1 -1
- package/dist/types/References.d.ts +13 -0
- package/package.json +1 -1
- package/skills/iyulab-chat-components/references/components/ref-block.md +6 -0
- package/skills/iyulab-chat-components/references/components/ref-card.md +1 -0
- package/skills/iyulab-chat-components/references/security.md +2 -2
- package/skills/iyulab-chat-components/references/types.md +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.19.0] - 2026-10-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **A citation source can carry a preview image** — `ReferenceSource.image` (`{ src, alt? }`, the shape of a
|
|
8
|
+
`u-images-block` item). `u-ref-card` draws it above the snippet, in `u-ref-block` and in the cards of an inline
|
|
9
|
+
citation's tooltip. Use it when the evidence is visual: a figure or chart taken from a document, a page
|
|
10
|
+
thumbnail, a web page's lead image. It passes the same origin policy as markdown images
|
|
11
|
+
(`setAllowedImagePrefixes`); a blocked image makes no request and its alt text shows as *Image blocked*.
|
|
12
|
+
|
|
3
13
|
## [0.18.1] - 2026-10-07
|
|
4
14
|
|
|
5
15
|
### Documentation
|
|
@@ -7,10 +7,10 @@ import { UElementBlock } from "./UElementBlock.js";
|
|
|
7
7
|
import { messages } from "../../utilities/messages.js";
|
|
8
8
|
import { markedKatex } from "../../utilities/markedKatex.js";
|
|
9
9
|
import "../references/URefTag.js";
|
|
10
|
+
import { resolveImageSource } from "../../utilities/imageSources.js";
|
|
10
11
|
import { URefCard } from "../references/URefCard.js";
|
|
11
12
|
import "../references/URefCardGroup.js";
|
|
12
13
|
import { UTableBlock } from "./UTableBlock.js";
|
|
13
|
-
import { resolveImageSource } from "../../utilities/imageSources.js";
|
|
14
14
|
import { HtmlPlaceholder, extractRefPlaceholders, stripRefPlaceholders } from "../../utilities/HtmlPlaceholder.js";
|
|
15
15
|
import { styles } from "./UMarkedBlock.styles.js";
|
|
16
16
|
import { nothing } from "lit";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UDataElement } from '../UDataElement.js';
|
|
2
|
+
import { ReferenceImage } from '../../types/References.js';
|
|
2
3
|
/**
|
|
3
4
|
* 웹 참조 카드의 파비콘 이미지 URL 을 정한다. `undefined` 를 돌려주면 파비콘 없이 그린다.
|
|
4
5
|
* @param url 카드의 `url`
|
|
@@ -34,6 +35,8 @@ export declare class URefCard extends UDataElement {
|
|
|
34
35
|
tags?: string[];
|
|
35
36
|
/** 이 카드의 파비콘 리졸버 — `URefCard.defaultFaviconUrl` 보다 우선한다. */
|
|
36
37
|
faviconUrl?: FaviconResolver;
|
|
38
|
+
/** 출처의 미리보기 이미지(`ReferenceSource.image`) — 이미지 출처 정책을 거친다. */
|
|
39
|
+
image?: ReferenceImage;
|
|
37
40
|
render(): import('lit-html').TemplateResult<1>;
|
|
38
41
|
/**
|
|
39
42
|
* script-payload(UMarkedBlock 툴팁)와 property 바인딩(URefBlock) 두 사용
|
|
@@ -45,6 +48,11 @@ export declare class URefCard extends UDataElement {
|
|
|
45
48
|
private handleAnchorClick;
|
|
46
49
|
/** 리졸버가 URL 을 돌려줄 때만 파비콘을 그린다(장식 — 제목이 이름을 나른다). */
|
|
47
50
|
private renderFavicon;
|
|
51
|
+
/**
|
|
52
|
+
* 미리보기 이미지 — 모델 출력의 이미지와 같은 출처 정책을 거친다. 막힌 이미지는 `<img>` 를 만들지 않는다(요청이 곧 반출
|
|
53
|
+
* 경로다) — 대체 텍스트를 «차단된 이미지» 로 보인다.
|
|
54
|
+
*/
|
|
55
|
+
private renderImage;
|
|
48
56
|
/** URL에서 도메인 사이트 주소를 반환합니다. */
|
|
49
57
|
private getDomainName;
|
|
50
58
|
}
|
|
@@ -5,6 +5,7 @@ import { sanitizeHref } from "../../utilities/sanitizers.js";
|
|
|
5
5
|
import { UDataElement } from "../UDataElement.js";
|
|
6
6
|
import { messages } from "../../utilities/messages.js";
|
|
7
7
|
import { styles } from "./URefCard.styles.js";
|
|
8
|
+
import { resolveImageSource } from "../../utilities/imageSources.js";
|
|
8
9
|
import { html, nothing } from "lit";
|
|
9
10
|
import { customElement, property } from "lit/decorators.js";
|
|
10
11
|
import "@iyulab/components/dist/components/icon/UIcon.js";
|
|
@@ -58,6 +59,8 @@ var URefCard = class URefCard extends UDataElement {
|
|
|
58
59
|
</div>
|
|
59
60
|
</div>
|
|
60
61
|
|
|
62
|
+
${this.renderImage()}
|
|
63
|
+
|
|
61
64
|
<div class="body">
|
|
62
65
|
${this.snippet}
|
|
63
66
|
</div>
|
|
@@ -92,6 +95,17 @@ var URefCard = class URefCard extends UDataElement {
|
|
|
92
95
|
if (!src) return nothing;
|
|
93
96
|
return html`<img class="favicon" src=${src} alt="" aria-hidden="true" />`;
|
|
94
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* 미리보기 이미지 — 모델 출력의 이미지와 같은 출처 정책을 거친다. 막힌 이미지는 `<img>` 를 만들지 않는다(요청이 곧 반출
|
|
100
|
+
* 경로다) — 대체 텍스트를 «차단된 이미지» 로 보인다.
|
|
101
|
+
*/
|
|
102
|
+
renderImage() {
|
|
103
|
+
const image = this.image;
|
|
104
|
+
if (!image?.src) return nothing;
|
|
105
|
+
const src = resolveImageSource(image.src);
|
|
106
|
+
if (src === null) return html`<div class="preview-blocked" part="preview-blocked">${image.alt ? messages.text("imageBlockedNamed", { name: image.alt }) : messages.text("imageBlocked")}</div>`;
|
|
107
|
+
return html`<img class="preview" part="preview" src=${src} alt=${image.alt ?? ""} loading="lazy" />`;
|
|
108
|
+
}
|
|
95
109
|
/** URL에서 도메인 사이트 주소를 반환합니다. */
|
|
96
110
|
getDomainName(url) {
|
|
97
111
|
if (!url) return "";
|
|
@@ -114,6 +128,7 @@ __decorate([property({
|
|
|
114
128
|
converter: arrayAttrConverter((v) => v)
|
|
115
129
|
}), __decorateMetadata("design:type", Array)], URefCard.prototype, "tags", void 0);
|
|
116
130
|
__decorate([property({ attribute: false }), __decorateMetadata("design:type", Object)], URefCard.prototype, "faviconUrl", void 0);
|
|
131
|
+
__decorate([property({ type: Object }), __decorateMetadata("design:type", Object)], URefCard.prototype, "image", void 0);
|
|
117
132
|
URefCard = _URefCard = __decorate([customElement("u-ref-card")], URefCard);
|
|
118
133
|
//#endregion
|
|
119
134
|
export { URefCard, googleFaviconUrl };
|
|
@@ -82,6 +82,23 @@ var styles = css`
|
|
|
82
82
|
margin-top: 8px;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/* 출처 미리보기 — 본문 위, 카드 폭 안. 도표·그림이 잘리지 않게 담는다(contain). */
|
|
86
|
+
.preview {
|
|
87
|
+
display: block;
|
|
88
|
+
align-self: flex-start;
|
|
89
|
+
max-width: 100%;
|
|
90
|
+
max-height: 160px;
|
|
91
|
+
margin-top: 8px;
|
|
92
|
+
object-fit: contain;
|
|
93
|
+
border-radius: 4px;
|
|
94
|
+
}
|
|
95
|
+
.preview-blocked {
|
|
96
|
+
margin-top: 8px;
|
|
97
|
+
color: var(--u-txt-color-weak);
|
|
98
|
+
font-size: 12px;
|
|
99
|
+
line-height: 1.5;
|
|
100
|
+
}
|
|
101
|
+
|
|
85
102
|
.footer {
|
|
86
103
|
display: flex;
|
|
87
104
|
gap: 4px;
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import { getElementBlockProperties, registerElementBlock } from "./utilities/Ele
|
|
|
6
6
|
import { UElementBlock } from "./components/blocks/UElementBlock.js";
|
|
7
7
|
import { UFileBlock } from "./components/blocks/UFileBlock.js";
|
|
8
8
|
import { URefTag } from "./components/references/URefTag.js";
|
|
9
|
+
import { getAllowedImagePrefixes, resolveImageSource, setAllowedImagePrefixes } from "./utilities/imageSources.js";
|
|
9
10
|
import { URefCard, googleFaviconUrl } from "./components/references/URefCard.js";
|
|
10
11
|
import { URefCardGroup } from "./components/references/URefCardGroup.js";
|
|
11
12
|
import { UTableBlock } from "./components/blocks/UTableBlock.js";
|
|
12
|
-
import { getAllowedImagePrefixes, resolveImageSource, setAllowedImagePrefixes } from "./utilities/imageSources.js";
|
|
13
13
|
import { UMarkedBlock } from "./components/blocks/UMarkedBlock.js";
|
|
14
14
|
import { UTextBlock } from "./components/blocks/UTextBlock.js";
|
|
15
15
|
import { URefBlock } from "./components/blocks/URefBlock.js";
|
|
@@ -12,6 +12,19 @@ export interface ReferenceSource {
|
|
|
12
12
|
snippet?: string;
|
|
13
13
|
/** 태그 */
|
|
14
14
|
tags?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* 출처의 미리보기 이미지 — 인용한 그림·도표 자체, 문서 쪽의 축소판, 웹 문서의 대표 이미지.
|
|
17
|
+
* 카드가 본문 위에 그린다. 모델 출력의 이미지와 같은 출처 정책(`setAllowedImagePrefixes`)을 거치며,
|
|
18
|
+
* 막히면 요청하지 않고 대체 텍스트를 «차단된 이미지» 로 보인다.
|
|
19
|
+
*/
|
|
20
|
+
image?: ReferenceImage;
|
|
21
|
+
}
|
|
22
|
+
/** 출처의 미리보기 이미지 — `u-images-block` 의 항목과 같은 모양이다. */
|
|
23
|
+
export interface ReferenceImage {
|
|
24
|
+
/** 이미지 URL */
|
|
25
|
+
src: string;
|
|
26
|
+
/** 대체 텍스트 — 이미지가 근거 자체(도표·그림)면 무엇을 보여 주는지 적는다. 없으면 장식으로 다룬다(카드 제목이 이름을 나른다). */
|
|
27
|
+
alt?: string;
|
|
15
28
|
}
|
|
16
29
|
/**
|
|
17
30
|
* 본문 내 참조 인용 정보입니다.
|
package/package.json
CHANGED
|
@@ -41,5 +41,11 @@ interface ReferenceSource {
|
|
|
41
41
|
title?: string; // Card title
|
|
42
42
|
snippet?: string; // Excerpt text
|
|
43
43
|
tags?: string[]; // Tag list
|
|
44
|
+
image?: ReferenceImage; // Preview image of the source (a figure, a page thumbnail, a page's lead image)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ReferenceImage {
|
|
48
|
+
src: string;
|
|
49
|
+
alt?: string;
|
|
44
50
|
}
|
|
45
51
|
```
|
|
@@ -47,6 +47,7 @@ Extends `UDataElement`, so data can also be injected via a `<script type="applic
|
|
|
47
47
|
| `snippet` | `string` | `undefined` | — | Excerpt text |
|
|
48
48
|
| `tags` | `string[]` | `undefined` | — | Tag list. Pass as JSON array string via HTML attribute |
|
|
49
49
|
| `faviconUrl` | `FaviconResolver` | `undefined` | — | Favicon resolver for this card (property only). Overrides `URefCard.defaultFaviconUrl` |
|
|
50
|
+
| `image` | `ReferenceImage` | `undefined` | — | Preview image (`{ src, alt? }`), drawn above the snippet. Passes the image origin policy (`setAllowedImagePrefixes`); a blocked image makes no request and shows its alt text as *Image blocked* |
|
|
50
51
|
|
|
51
52
|
---
|
|
52
53
|
|
|
@@ -7,12 +7,12 @@ is trusted to contain:
|
|
|
7
7
|
|---|---|---|
|
|
8
8
|
| `u-marked-block` `value` | untrusted | Raw HTML shown as text · link/image URLs protocol-checked (`javascript:`/`data:`/`vbscript:`/`//host` → `#`) · code fences escaped · table cells same rules |
|
|
9
9
|
| `block-json` fences | untrusted | Only registered blocks; only the schema's property names are assigned |
|
|
10
|
-
| `refs` | untrusted | Text rendered as text · URLs protocol-checked in `u-ref-tag` and `u-ref-card` |
|
|
10
|
+
| `refs` | untrusted | Text rendered as text · URLs protocol-checked in `u-ref-tag` and `u-ref-card` · a source `image` passes the image origin policy |
|
|
11
11
|
| `u-table-block` cell `text` bound directly | untrusted | Rendered as text; search, sort and downloads use it |
|
|
12
12
|
| `u-table-block` cell `html` bound directly | **trusted HTML** | Display only. Sanitize before binding. `block-json` cannot reach it |
|
|
13
13
|
| Your custom block | your element's contract | The schema allows names, not content — sanitize HTML-rendered properties inside the element |
|
|
14
14
|
|
|
15
|
-
Requests: markdown images
|
|
15
|
+
Requests: markdown images, `u-images-block` and citation previews (`ReferenceSource.image`) load the `http:`/`https:` URL the model writes as soon as they
|
|
16
16
|
render (an image URL can carry data out). When the model reads content you do not control, call
|
|
17
17
|
`setAllowedImagePrefixes([location.origin + '/', 'https://cdn.example.com/images/'])` before rendering —
|
|
18
18
|
images outside the list are not requested and show their alt text (`Image blocked: …`). Prefixes match the
|
|
@@ -68,6 +68,13 @@ interface ReferenceSource {
|
|
|
68
68
|
title?: string;
|
|
69
69
|
snippet?: string;
|
|
70
70
|
tags?: string[];
|
|
71
|
+
image?: ReferenceImage;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Preview image of a source — the same shape as a `u-images-block` item. Passes the image origin policy. */
|
|
75
|
+
interface ReferenceImage {
|
|
76
|
+
src: string;
|
|
77
|
+
alt?: string; // say what a figure shows; omit for a decorative image (the card title names the card)
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
interface ReferenceCitation {
|