@iyulab/chat-components 0.13.0 โ 0.14.1
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 +72 -0
- package/README.md +1 -0
- package/dist/_virtual/_glob-assets_raw/alert-triangle-fill.svg.4cfc4305.js +4 -0
- package/dist/_virtual/_glob-assets_raw/arrows-sort.svg.dda43a85.js +4 -0
- package/dist/_virtual/_glob-assets_raw/code.svg.c69bc144.js +4 -0
- package/dist/_virtual/_glob-assets_raw/download.svg.bce82177.js +4 -0
- package/dist/_virtual/_glob-assets_raw/external-link.svg.a9f7f02d.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-code.svg.0e706f93.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-music.svg.b9970203.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-spreadsheet.svg.8c03bdfa.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-text.svg.85bdd923.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-type-pdf.svg.bc12db6d.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-zip.svg.76dde660.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file.svg.28f5d6f1.js +4 -0
- package/dist/_virtual/_glob-assets_raw/photo.svg.cc273cc1.js +4 -0
- package/dist/_virtual/_glob-assets_raw/player-stop-fill.svg.5378b752.js +4 -0
- package/dist/_virtual/_glob-assets_raw/send.svg.02326253.js +4 -0
- package/dist/_virtual/_glob-assets_raw/sort-ascending-letters.svg.14a3df67.js +4 -0
- package/dist/_virtual/_glob-assets_raw/sort-descending-letters.svg.3e03647c.js +4 -0
- package/dist/_virtual/_glob-assets_raw/video.svg.c183f03c.js +4 -0
- package/dist/_virtual/_glob-assets_raw/world.svg.cd9903c8.js +4 -0
- package/dist/components/UDataElement.d.ts +2 -0
- package/dist/components/UDataElement.js +9 -1
- package/dist/components/blocks/UCodeBlock.js +1 -0
- package/dist/components/blocks/UElementBlock.d.ts +12 -16
- package/dist/components/blocks/UElementBlock.js +23 -31
- package/dist/components/blocks/UFileBlock.js +1 -0
- package/dist/components/blocks/UMarkedBlock.d.ts +10 -1
- package/dist/components/blocks/UMarkedBlock.js +43 -13
- package/dist/components/blocks/UMarkedBlock.styles.js +10 -0
- package/dist/components/blocks/UTableBlock.js +1 -0
- package/dist/components/prompt/UPrompt.js +3 -1
- package/dist/components/references/URefCard.js +3 -1
- package/dist/components/references/URefTag.js +3 -1
- package/dist/components-extra/UChartBlock.js +4 -0
- package/dist/components-extra/UImagesBlock.d.ts +3 -0
- package/dist/components-extra/UImagesBlock.js +18 -3
- package/dist/components-extra/UImagesBlock.styles.js +19 -0
- package/dist/components-extra/UMapBlock.js +3 -0
- package/dist/components-extra/UVideoBlock.js +3 -0
- package/dist/extra.d.ts +7 -1
- package/dist/extra.js +12 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -2
- package/dist/utilities/ElementRegistry.d.ts +13 -0
- package/dist/utilities/ElementRegistry.js +33 -0
- package/dist/utilities/HtmlPlaceholder.d.ts +8 -0
- package/dist/utilities/HtmlPlaceholder.js +13 -1
- package/dist/utilities/PromptBuilder.d.ts +3 -0
- package/dist/utilities/PromptBuilder.js +5 -0
- package/dist/utilities/icons.js +52 -0
- package/dist/utilities/imageSources.d.ts +25 -0
- package/dist/utilities/imageSources.js +61 -0
- package/dist/utilities/messages.d.ts +1 -1
- package/dist/utilities/messages.js +6 -2
- package/dist/utilities/sanitizers.d.ts +10 -1
- package/dist/utilities/sanitizers.js +16 -5
- package/package.json +4 -2
- package/skills/iyulab-chat-components/SKILL.md +1 -0
- package/skills/iyulab-chat-components/references/components/element-block.md +5 -6
- package/skills/iyulab-chat-components/references/components/images-block.md +1 -0
- package/skills/iyulab-chat-components/references/components/marked-block.md +17 -0
- package/skills/iyulab-chat-components/references/extra-system.md +4 -4
- package/skills/iyulab-chat-components/references/security.md +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.14.1] - 2026-09-30
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **A citation whose index falls inside a link URL, an image, or inline code no longer breaks it.**
|
|
8
|
+
The citation markup was restored into the `href` attribute (the link pointed at a truncated URL
|
|
9
|
+
followed by markup) or into the `<code>` text. It is now placed right after the link, image, or code.
|
|
10
|
+
- **A citation that points past the text received so far is held until that text arrives.** During
|
|
11
|
+
streaming it used to be drawn at the end of the partial text and then jump to its place.
|
|
12
|
+
- A citation with a negative or non-integer index is ignored. A negative index used to be counted
|
|
13
|
+
from the end of the text and inserted mid-word.
|
|
14
|
+
|
|
15
|
+
## [0.14.0] - 2026-09-30
|
|
16
|
+
|
|
17
|
+
### Security
|
|
18
|
+
|
|
19
|
+
- ๐ด **Breaking โ `block-json` renders only registered blocks and assigns only their schema's
|
|
20
|
+
properties.** `u-element-block` used to create any element defined on the page and assign every
|
|
21
|
+
property except six names (`innerHTML`, `outerHTML`, โฆ). `block-json` is model output, so a
|
|
22
|
+
prompt-injected document could create an element that renders a property as HTML (for example
|
|
23
|
+
`u-table-block`'s cell text) and run script. Now a tag must be registered as a block, and only the
|
|
24
|
+
names in that block's schema `properties` are assigned; other keys (including `style`) are dropped
|
|
25
|
+
and logged to the console.
|
|
26
|
+
- The four built-in extras register themselves when their module is imported, and
|
|
27
|
+
`ElementPromptBuilder.add()` registers the schema it is given โ extras set up as documented keep
|
|
28
|
+
working.
|
|
29
|
+
- New `registerElementBlock(schema)` for blocks you describe in your own prompt, and
|
|
30
|
+
`getElementBlockProperties(tag)`.
|
|
31
|
+
- The `blacklist` property of `u-element-block` is removed.
|
|
32
|
+
- **New `setAllowedImagePrefixes(prefixes)` โ an origin policy for images in model output.** Markdown
|
|
33
|
+
images in `u-marked-block` (table cells included) and the items of `u-images-block` load the URL the
|
|
34
|
+
model wrote as soon as they render, so a prompt-injected response can send data to a third party in
|
|
35
|
+
an image URL's query string. With a list set, only images whose resolved absolute URL starts with one
|
|
36
|
+
of the prefixes are requested; any other image is drawn as its alt text (`Image blocked: โฆ`,
|
|
37
|
+
localized) and no request is made. The default (`undefined`) keeps loading every image; `[]` blocks
|
|
38
|
+
all, `['*']` allows all. `getAllowedImagePrefixes()` and `resolveImageSource(src)` are exported too.
|
|
39
|
+
- `data:image/โฆ` URLs make no request and are shown under any policy โ markdown images with such a
|
|
40
|
+
URL used to be replaced by `#`.
|
|
41
|
+
- A markdown image with a blocked protocol (`javascript:` and the like) is drawn as its alt text
|
|
42
|
+
instead of `<img src="#">`, which requested the page itself as an image.
|
|
43
|
+
- `u-images-block` now applies the same protocol check to `src` as markdown images do.
|
|
44
|
+
- New `docs/security.md` (and a skill reference) โ what each input is trusted to contain, the requests
|
|
45
|
+
the components make, and what is left to the application.
|
|
46
|
+
- New `sanitizeHref(url)` โ the protocol check without HTML escaping, for property bindings.
|
|
47
|
+
- Migration: a custom element that `block-json` should render needs its schema registered with
|
|
48
|
+
`ElementPromptBuilder.add()` or `registerElementBlock()`, and every property the model may set
|
|
49
|
+
must be listed in that schema's `properties`.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- **`u-ref-card` checks the protocol of its `url`, like `u-ref-tag` already did.** A citation source URL
|
|
54
|
+
such as `javascript:โฆ` became `#` in the inline citation but stayed as written in the card inside its
|
|
55
|
+
tooltip. Both now use the same check.
|
|
56
|
+
- **`u-prompt` no longer sends on the Enter that finishes an IME composition.** Typing Korean (or
|
|
57
|
+
another composed language) and pressing Enter sent the message and then left the last syllable in
|
|
58
|
+
the box, so it was sent again. Requires `@iyulab/components` 1.51.0 or later.
|
|
59
|
+
- **Icons of `u-prompt`, `u-table-block`, `u-code-block` and the other components that use the
|
|
60
|
+
bundled `internal-chat` set are drawn again.** The module that registers that set had no exports
|
|
61
|
+
and was not declared in `sideEffects`, so the package build dropped it and those icons rendered at
|
|
62
|
+
0ร0 (0.11.1 โ 0.13.0).
|
|
63
|
+
- **A table whose cell carries a citation keeps its rows.** The citation markup was inserted into the
|
|
64
|
+
table's JSON payload after it had been serialized, which broke the JSON, and the table rendered
|
|
65
|
+
empty. Citations inside `block-json` payloads are removed for the same reason.
|
|
66
|
+
- **`u-marked-block` keeps updating after it is detached and re-attached while a render or the
|
|
67
|
+
streaming indicator is pending.** It used to stop updating for good, showing an intermediate
|
|
68
|
+
frame, or leave a `block-json` block on its loading skeleton.
|
|
69
|
+
- Blocks that read their data from a `<script type="application/json">` child no longer log a
|
|
70
|
+
"Missing script" error when they are moved in the DOM after loading.
|
|
71
|
+
- `@iyulab/chat-components/extra` registers the built-in extras on `ElementPromptBuilder.instance`,
|
|
72
|
+
as documented. Adding your own extras there and calling `build()` again now returns the built-ins
|
|
73
|
+
too; it used to return only yours.
|
|
74
|
+
|
|
3
75
|
## [0.13.0] - 2026-09-28
|
|
4
76
|
|
|
5
77
|
### Fixed
|
package/README.md
CHANGED
|
@@ -137,6 +137,7 @@ package's Accessibility section.
|
|
|
137
137
|
| [docs/block-system.md](./docs/block-system.md) | Block components and `BlockItem` types in depth |
|
|
138
138
|
| [docs/extras-system.md](./docs/extras-system.md) | Extras system setup and custom extras |
|
|
139
139
|
| [docs/events.md](./docs/events.md) | Full event reference |
|
|
140
|
+
| [docs/security.md](./docs/security.md) | What each input is trusted to contain, requests the components make, and your application's part |
|
|
140
141
|
|
|
141
142
|
---
|
|
142
143
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/alert-triangle-fill.svg.4cfc4305
|
|
2
|
+
var alert_triangle_fill_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { alert_triangle_fill_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/arrows-sort.svg.dda43a85
|
|
2
|
+
var arrows_sort_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M3 9l4 -4l4 4m-4 -4v14\" />\n <path d=\"M21 15l-4 4l-4 -4m4 4v-14\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { arrows_sort_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/code.svg.c69bc144
|
|
2
|
+
var code_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M7 8l-4 4l4 4\" />\n <path d=\"M17 8l4 4l-4 4\" />\n <path d=\"M14 4l-4 16\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { code_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/download.svg.bce82177
|
|
2
|
+
var download_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2\" />\n <path d=\"M7 11l5 5l5 -5\" />\n <path d=\"M12 4l0 12\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { download_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/external-link.svg.a9f7f02d
|
|
2
|
+
var external_link_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6\" />\n <path d=\"M11 13l9 -9\" />\n <path d=\"M15 4h5v5\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { external_link_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file-code.svg.0e706f93
|
|
2
|
+
var file_code_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2\" />\n <path d=\"M10 13l-1 2l1 2\" />\n <path d=\"M14 13l1 2l-1 2\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_code_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file-music.svg.b9970203
|
|
2
|
+
var file_music_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2\" />\n <path d=\"M10 16a1 1 0 1 0 2 0a1 1 0 1 0 -2 0\" />\n <path d=\"M12 16l0 -5l2 1\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_music_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file-spreadsheet.svg.8c03bdfa
|
|
2
|
+
var file_spreadsheet_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2\" />\n <path d=\"M8 11h8v7h-8l0 -7\" />\n <path d=\"M8 15h8\" />\n <path d=\"M11 11v7\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_spreadsheet_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file-text.svg.85bdd923
|
|
2
|
+
var file_text_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2\" />\n <path d=\"M9 9l1 0\" />\n <path d=\"M9 13l6 0\" />\n <path d=\"M9 17l6 0\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_text_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file-type-pdf.svg.bc12db6d
|
|
2
|
+
var file_type_pdf_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4\" />\n <path d=\"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6\" />\n <path d=\"M17 18h2\" />\n <path d=\"M20 15h-3v6\" />\n <path d=\"M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_type_pdf_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file-zip.svg.76dde660
|
|
2
|
+
var file_zip_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M6 20.735a2 2 0 0 1 -1 -1.735v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-1\" />\n <path d=\"M11 17a2 2 0 0 1 2 2v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-2a2 2 0 0 1 2 -2\" />\n <path d=\"M11 5l-1 0\" />\n <path d=\"M13 7l-1 0\" />\n <path d=\"M11 9l-1 0\" />\n <path d=\"M13 11l-1 0\" />\n <path d=\"M11 13l-1 0\" />\n <path d=\"M13 15l-1 0\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_zip_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/file.svg.28f5d6f1
|
|
2
|
+
var file_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { file_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/photo.svg.cc273cc1
|
|
2
|
+
var photo_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M15 8h.01\" />\n <path d=\"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12\" />\n <path d=\"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5\" />\n <path d=\"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { photo_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/player-stop-fill.svg.5378b752
|
|
2
|
+
var player_stop_fill_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { player_stop_fill_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/send.svg.02326253
|
|
2
|
+
var send_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M10 14l11 -11\" />\n <path d=\"M21 3l-6.5 18a.55 .55 0 0 1 -1 0l-3.5 -7l-7 -3.5a.55 .55 0 0 1 0 -1l18 -6.5\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { send_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/sort-ascending-letters.svg.14a3df67
|
|
2
|
+
var sort_ascending_letters_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M15 10v-5c0 -1.38 .62 -2 2 -2s2 .62 2 2v5m0 -3h-4\" />\n <path d=\"M19 21h-4l4 -7h-4\" />\n <path d=\"M4 15l3 3l3 -3\" />\n <path d=\"M7 6v12\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { sort_ascending_letters_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/sort-descending-letters.svg.3e03647c
|
|
2
|
+
var sort_descending_letters_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M15 21v-5c0 -1.38 .62 -2 2 -2s2 .62 2 2v5m0 -3h-4\" />\n <path d=\"M19 10h-4l4 -7h-4\" />\n <path d=\"M4 15l3 3l3 -3\" />\n <path d=\"M7 6v12\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { sort_descending_letters_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/video.svg.c183f03c
|
|
2
|
+
var video_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M15 10l4.553 -2.276a1 1 0 0 1 1.447 .894v6.764a1 1 0 0 1 -1.447 .894l-4.553 -2.276v-4\" />\n <path d=\"M3 8a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -8\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { video_svg_default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region \0glob-assets_raw/world.svg.cd9903c8
|
|
2
|
+
var world_svg_default = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0\" />\n <path d=\"M3.6 9h16.8\" />\n <path d=\"M3.6 15h16.8\" />\n <path d=\"M11.5 3a17 17 0 0 0 0 18\" />\n <path d=\"M12.5 3a17 17 0 0 1 0 18\" />\n</svg>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { world_svg_default as default };
|
|
@@ -18,6 +18,8 @@ import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class UDataElement extends UElement {
|
|
20
20
|
static styles: import('lit').CSSResultGroup;
|
|
21
|
+
/** ๋ฐ์ดํฐ๋ฅผ ํ ๋ฒ์ด๋ผ๋ ์ฝ์๋๊ฐ โ ์ฌ์ฐ๊ฒฐ ๋ ยซ์คํฌ๋ฆฝํธ ์์ยป ์ ์ค๋ฅ๋ก ๋ณด์ง ์๊ธฐ ์ํด. */
|
|
22
|
+
private loaded;
|
|
21
23
|
connectedCallback(): void;
|
|
22
24
|
/**
|
|
23
25
|
* ์ง์ ํ ํ๊ทธ์ ๋ฐ์ดํฐ๋ก ์ปค์คํ
์๋ฆฌ๋จผํธ HTML ๋ฌธ์์ด์ ์์ฑํฉ๋๋ค.
|
|
@@ -19,6 +19,10 @@ import { UElement } from "@iyulab/components/dist/components/UElement.js";
|
|
|
19
19
|
* (์: `URefCard` โ URefBlock์ property ๊ตฌ๋๊ณผ UMarkedBlock์ script ์ฃผ์
์ ๋ชจ๋ ์ง์)
|
|
20
20
|
*/
|
|
21
21
|
var UDataElement = class extends UElement {
|
|
22
|
+
constructor(..._args) {
|
|
23
|
+
super(..._args);
|
|
24
|
+
this.loaded = false;
|
|
25
|
+
}
|
|
22
26
|
static {
|
|
23
27
|
this.styles = super.styles;
|
|
24
28
|
}
|
|
@@ -55,12 +59,16 @@ var UDataElement = class extends UElement {
|
|
|
55
59
|
try {
|
|
56
60
|
if (!data) {
|
|
57
61
|
const script = this.querySelector("script[type=\"application/json\"]");
|
|
58
|
-
if (!script)
|
|
62
|
+
if (!script) {
|
|
63
|
+
if (this.loaded) return;
|
|
64
|
+
throw new Error("Missing <script type=\"application/json\">");
|
|
65
|
+
}
|
|
59
66
|
data = JSON.parse(script.textContent ?? "{}");
|
|
60
67
|
script.remove();
|
|
61
68
|
}
|
|
62
69
|
if (typeof data !== "object" || data === null || Array.isArray(data)) throw new Error("Invalid JSON data: expected an object at the top level");
|
|
63
70
|
Object.assign(this, data);
|
|
71
|
+
this.loaded = true;
|
|
64
72
|
} catch (error) {
|
|
65
73
|
await this.error(error);
|
|
66
74
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../utilities/icons.js";
|
|
1
2
|
import { styles } from "./UCodeBlock.styles.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { nothing, PropertyValues } from 'lit';
|
|
2
2
|
import { UDataElement } from '../UDataElement.js';
|
|
3
3
|
/**
|
|
4
|
-
* `block-json` ์ฝ๋ํ์ค์์ ์ง์ ํ
|
|
4
|
+
* `block-json` ์ฝ๋ํ์ค์์ ์ง์ ํ ๋ธ๋ก์ ๋์ ์ผ๋ก ๋ ๋๋งํ๋ ์ปดํฌ๋ํธ์
๋๋ค.
|
|
5
|
+
*
|
|
6
|
+
* ๋ง๋ค ์ ์๋ ๊ฒ์ **๋ธ๋ก์ผ๋ก ๋ฑ๋ก๋ ํ๊ทธ๋ฟ**์ด๊ณ (`registerElementBlock` ยท
|
|
7
|
+
* `ElementPromptBuilder.add`), ๋์
ํ๋ ๊ฒ์ **๊ทธ ์คํค๋ง์ `properties` ์ ์ ํ ์ด๋ฆ๋ฟ**์
๋๋ค.
|
|
8
|
+
* `tag`ยท`properties` ๋ LLM ์ถ๋ ฅ์์ ์ค๋ฏ๋ก ์ ๋ขฐํ ์ ์๋ ์
๋ ฅ์ผ๋ก ๋ค๋ฃน๋๋ค โ ์คํค๋ง ๋ฐ์
|
|
9
|
+
* ์ด๋ฆ์ ๋์
ํ์ง ์๊ณ ์ฝ์์ ๊ธฐ๋กํฉ๋๋ค.
|
|
5
10
|
* ๋์ ํ๊ทธ๊ฐ ๋ฑ๋ก๋์ด ์์ง ์๊ฑฐ๋ ๋ฐ์ดํฐ๊ฐ ์ ํจํ์ง ์์ ๊ฒฝ์ฐ, ์๋ฌ ์นด๋ ์์ด ์ฝ์์๋ง ๊ธฐ๋กํ๊ณ ์๋ฌด๊ฒ๋ ๋ ๋๋งํ์ง ์์ต๋๋ค.
|
|
6
11
|
*/
|
|
7
12
|
export declare class UElementBlock extends UDataElement {
|
|
8
13
|
static styles: import('lit').CSSResultGroup[];
|
|
9
14
|
/** ๋ก๋ฉ ์ํ์
๋๋ค. `true`์ธ ๊ฒฝ์ฐ, ์์ ฏ์ด ๋ก๋ฉ ์ค์์ ๋ํ๋
๋๋ค. */
|
|
10
15
|
loading: boolean;
|
|
11
|
-
/**
|
|
16
|
+
/** ๋ ๋๋งํ ๋ธ๋ก์ ํ๊ทธ์
๋๋ค. ๋ธ๋ก์ผ๋ก ๋ฑ๋ก๋ ํ๊ทธ๋ง ๋ ๋๋ง๋ฉ๋๋ค. */
|
|
12
17
|
tag?: string;
|
|
13
|
-
/**
|
|
18
|
+
/** ๋ธ๋ก์ ๋์
ํ ๊ฐ์
๋๋ค. ๋ธ๋ก ์คํค๋ง์ `properties` ์ ์ ํ ์ด๋ฆ๋ง ๋์
๋ฉ๋๋ค. */
|
|
14
19
|
properties?: Record<string, unknown>;
|
|
15
|
-
/** `properties` ๊ฐ์ฒด์์ ์ํํ ํ๋กํผํฐ ์ด๋ฆ์ ์ง์ ํ์ฌ ์ฐจ๋จํ ์ ์์ต๋๋ค. */
|
|
16
|
-
blacklist: string[];
|
|
17
20
|
/** ์ค์ ๋ ๋๋ง๋ ์๋ฆฌ๋จผํธ์
๋๋ค. `tag` ํ๋กํผํฐ๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ์
๋ฐ์ดํธ๋ฉ๋๋ค. */
|
|
18
21
|
private element;
|
|
19
22
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
@@ -24,24 +27,17 @@ export declare class UElementBlock extends UDataElement {
|
|
|
24
27
|
*/
|
|
25
28
|
protected error(error: unknown): Promise<void>;
|
|
26
29
|
/**
|
|
27
|
-
* `tag
|
|
28
|
-
*
|
|
29
|
-
* `tag`๊ฐ ์ ํจํ์ง ์๊ฑฐ๋ ๋ฑ๋ก๋ ์ปค์คํ
์๋ฆฌ๋จผํธ๊ฐ ์๋ ๊ฒฝ์ฐ, ์๋ฌ ์ฒ๋ฆฌํฉ๋๋ค.
|
|
30
|
+
* `tag`๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ๋ธ๋ก ์๋ฆฌ๋จผํธ๋ฅผ ์๋ก ์์ฑํฉ๋๋ค.
|
|
31
|
+
* ๋ธ๋ก์ผ๋ก ๋ฑ๋ก๋์ง ์์ ํ๊ทธ๋ ์์ง ์ ์๋์ง ์์ ์ปค์คํ
์๋ฆฌ๋จผํธ๋ ๋ง๋ค์ง ์๊ณ ๊ธฐ๋ก๋ง ํฉ๋๋ค.
|
|
30
32
|
* JSON ์์ฒด๋ ์ด๋ฏธ ํ์ฑ์ ์ฑ๊ณตํ ์ํ์ด๋ฏ๋ก(์คํธ๋ฆฌ๋ฐ ์ค ํ์ฑ ์คํจ์๋ ๋ค๋ฅธ ์ผ์ด์ค),
|
|
31
33
|
* `loading` ์ฌ๋ถ์ ๋ฌด๊ดํ๊ฒ ํญ์ ๊ธฐ๋กํฉ๋๋ค.
|
|
32
34
|
*/
|
|
33
35
|
private updateElement;
|
|
34
36
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* ํ ๋น ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ, ์๋ฌ ์ฒ๋ฆฌํฉ๋๋ค.
|
|
37
|
+
* ๋ธ๋ก ์คํค๋ง์ ์ ํ ์ด๋ฆ๋ง ๋์
ํฉ๋๋ค. ์คํค๋ง ๋ฐ์ ์ด๋ฆ์ ๋์
ํ์ง ์๊ณ ๊ธฐ๋กํฉ๋๋ค โ
|
|
38
|
+
* ๋ธ๋ก ํ๋๋ฅผ ํต์งธ๋ก ๋ฒ๋ฆฌ์ง ์๋ ๊ฒ์ LLM ์ด ๋ฌดํดํ ์ฌ๋ถ ํค๋ฅผ ๋ถ์ด๋ ์ผ์ด ํํ๊ธฐ ๋๋ฌธ์
๋๋ค.
|
|
38
39
|
*/
|
|
39
40
|
private updateProperties;
|
|
40
|
-
/**
|
|
41
|
-
* `properties` ๊ฐ์ฒด์ ์ํํ ํ๋กํผํฐ๊ฐ ํฌํจ๋์ด ์๋์ง ๊ฒ์ฆํฉ๋๋ค.
|
|
42
|
-
* DOM ์กฐ์์ด๋ ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ก ์
์ฉ๋ ์ ์๋ ํ๋กํผํฐ๋ฅผ ์ต์ํ์ผ๋ก ์ฐจ๋จํฉ๋๋ค.
|
|
43
|
-
*/
|
|
44
|
-
private validateProperties;
|
|
45
41
|
/**
|
|
46
42
|
* ์๋ฌ ์นด๋ ์์ด ์ฝ์์๋ง ๊ธฐ๋กํฉ๋๋ค. ์ฑํ
UI์ ๊ฐ์์ค๋ฌ์ด ์๋ฌ ์นด๋๊ฐ ๋จ๋ ๊ฒ์ ํผํ๊ธฐ ์ํจ์
๋๋ค โ
|
|
47
43
|
* addon ๋ชจ๋์ importํ์ง ์์ ์์ง ๋ฑ๋ก๋์ง ์์ ํ๊ทธ์ผ ์๋ ์์ผ๋ฏ๋ก, ์ค์ ์๋ฌ๋ผ๊ธฐ๋ณด๋ค
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
|
|
2
2
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
|
|
3
3
|
import { UDataElement } from "../UDataElement.js";
|
|
4
|
+
import { getElementBlockProperties } from "../../utilities/ElementRegistry.js";
|
|
4
5
|
import { styles } from "./UElementBlock.styles.js";
|
|
5
6
|
import { html, nothing } from "lit";
|
|
6
7
|
import { customElement, property, state } from "lit/decorators.js";
|
|
7
8
|
import "@iyulab/components/dist/components/skeleton/USkeleton.js";
|
|
8
9
|
//#region src/components/blocks/UElementBlock.ts
|
|
9
|
-
var DEFAULT_BLACKLIST = [
|
|
10
|
-
"innerHTML",
|
|
11
|
-
"outerHTML",
|
|
12
|
-
"textContent",
|
|
13
|
-
"innerText",
|
|
14
|
-
"outerText",
|
|
15
|
-
"srcdoc"
|
|
16
|
-
];
|
|
17
10
|
var UElementBlock = class UElementBlock extends UDataElement {
|
|
18
11
|
constructor(..._args) {
|
|
19
12
|
super(..._args);
|
|
20
13
|
this.loading = false;
|
|
21
|
-
this.blacklist = DEFAULT_BLACKLIST;
|
|
22
14
|
this.element = null;
|
|
23
15
|
}
|
|
24
16
|
static {
|
|
@@ -27,8 +19,7 @@ var UElementBlock = class UElementBlock extends UDataElement {
|
|
|
27
19
|
willUpdate(changedProperties) {
|
|
28
20
|
super.willUpdate(changedProperties);
|
|
29
21
|
if (changedProperties.has("tag")) this.updateElement(this.tag);
|
|
30
|
-
if (changedProperties.has("properties") && this.element) this.updateProperties(this.element, this.properties);
|
|
31
|
-
if (changedProperties.has("blacklist") && this.element && this.properties) this.updateProperties(this.element, this.properties);
|
|
22
|
+
if ((changedProperties.has("properties") || changedProperties.has("tag")) && this.element && this.properties) this.updateProperties(this.element, this.properties);
|
|
32
23
|
}
|
|
33
24
|
render() {
|
|
34
25
|
if (this.loading === true) return html`
|
|
@@ -54,9 +45,8 @@ var UElementBlock = class UElementBlock extends UDataElement {
|
|
|
54
45
|
this.reportError(error);
|
|
55
46
|
}
|
|
56
47
|
/**
|
|
57
|
-
* `tag
|
|
58
|
-
*
|
|
59
|
-
* `tag`๊ฐ ์ ํจํ์ง ์๊ฑฐ๋ ๋ฑ๋ก๋ ์ปค์คํ
์๋ฆฌ๋จผํธ๊ฐ ์๋ ๊ฒฝ์ฐ, ์๋ฌ ์ฒ๋ฆฌํฉ๋๋ค.
|
|
48
|
+
* `tag`๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ๋ธ๋ก ์๋ฆฌ๋จผํธ๋ฅผ ์๋ก ์์ฑํฉ๋๋ค.
|
|
49
|
+
* ๋ธ๋ก์ผ๋ก ๋ฑ๋ก๋์ง ์์ ํ๊ทธ๋ ์์ง ์ ์๋์ง ์์ ์ปค์คํ
์๋ฆฌ๋จผํธ๋ ๋ง๋ค์ง ์๊ณ ๊ธฐ๋ก๋ง ํฉ๋๋ค.
|
|
60
50
|
* JSON ์์ฒด๋ ์ด๋ฏธ ํ์ฑ์ ์ฑ๊ณตํ ์ํ์ด๋ฏ๋ก(์คํธ๋ฆฌ๋ฐ ์ค ํ์ฑ ์คํจ์๋ ๋ค๋ฅธ ์ผ์ด์ค),
|
|
61
51
|
* `loading` ์ฌ๋ถ์ ๋ฌด๊ดํ๊ฒ ํญ์ ๊ธฐ๋กํฉ๋๋ค.
|
|
62
52
|
*/
|
|
@@ -67,6 +57,11 @@ var UElementBlock = class UElementBlock extends UDataElement {
|
|
|
67
57
|
this.reportError(/* @__PURE__ */ new Error("Tag is required"));
|
|
68
58
|
return;
|
|
69
59
|
}
|
|
60
|
+
if (!getElementBlockProperties(tag)) {
|
|
61
|
+
this.element = null;
|
|
62
|
+
this.reportError(/* @__PURE__ */ new Error(`"${tag}" is not a registered element block โ register its schema with registerElementBlock() or ElementPromptBuilder.add()`));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
70
65
|
if (!customElements.get(tag)) {
|
|
71
66
|
this.element = null;
|
|
72
67
|
this.reportError(/* @__PURE__ */ new Error(`Unknown tag: ${tag}`));
|
|
@@ -75,27 +70,25 @@ var UElementBlock = class UElementBlock extends UDataElement {
|
|
|
75
70
|
this.element = document.createElement(tag);
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* ํ ๋น ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ, ์๋ฌ ์ฒ๋ฆฌํฉ๋๋ค.
|
|
73
|
+
* ๋ธ๋ก ์คํค๋ง์ ์ ํ ์ด๋ฆ๋ง ๋์
ํฉ๋๋ค. ์คํค๋ง ๋ฐ์ ์ด๋ฆ์ ๋์
ํ์ง ์๊ณ ๊ธฐ๋กํฉ๋๋ค โ
|
|
74
|
+
* ๋ธ๋ก ํ๋๋ฅผ ํต์งธ๋ก ๋ฒ๋ฆฌ์ง ์๋ ๊ฒ์ LLM ์ด ๋ฌดํดํ ์ฌ๋ถ ํค๋ฅผ ๋ถ์ด๋ ์ผ์ด ํํ๊ธฐ ๋๋ฌธ์
๋๋ค.
|
|
81
75
|
*/
|
|
82
76
|
updateProperties(element, props) {
|
|
83
|
-
if (
|
|
84
|
-
|
|
77
|
+
if (typeof props !== "object" || props === null || Array.isArray(props)) {
|
|
78
|
+
this.reportError(/* @__PURE__ */ new Error(`Properties must be an object: ${JSON.stringify(props)}`));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const allowed = getElementBlockProperties(element.localName) ?? /* @__PURE__ */ new Set();
|
|
82
|
+
const accepted = {};
|
|
83
|
+
const rejected = [];
|
|
84
|
+
for (const [key, value] of Object.entries(props)) if (allowed.has(key)) accepted[key] = value;
|
|
85
|
+
else rejected.push(key);
|
|
86
|
+
if (rejected.length > 0) this.reportError(/* @__PURE__ */ new Error(`Not in the "${element.localName}" schema, not assigned: ${rejected.join(", ")}`));
|
|
87
|
+
try {
|
|
88
|
+
Object.assign(element, accepted);
|
|
85
89
|
} catch (error) {
|
|
86
90
|
this.reportError(error);
|
|
87
91
|
}
|
|
88
|
-
else this.reportError(/* @__PURE__ */ new Error(`Not allowed properties: ${JSON.stringify(props)}`));
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* `properties` ๊ฐ์ฒด์ ์ํํ ํ๋กํผํฐ๊ฐ ํฌํจ๋์ด ์๋์ง ๊ฒ์ฆํฉ๋๋ค.
|
|
92
|
-
* DOM ์กฐ์์ด๋ ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ก ์
์ฉ๋ ์ ์๋ ํ๋กํผํฐ๋ฅผ ์ต์ํ์ผ๋ก ์ฐจ๋จํฉ๋๋ค.
|
|
93
|
-
*/
|
|
94
|
-
validateProperties(props) {
|
|
95
|
-
if (typeof props !== "object" || props === null || Array.isArray(props)) return false;
|
|
96
|
-
const obj = props;
|
|
97
|
-
for (const key of Object.keys(obj)) if (this.blacklist.includes(key)) return false;
|
|
98
|
-
return true;
|
|
99
92
|
}
|
|
100
93
|
/**
|
|
101
94
|
* ์๋ฌ ์นด๋ ์์ด ์ฝ์์๋ง ๊ธฐ๋กํฉ๋๋ค. ์ฑํ
UI์ ๊ฐ์์ค๋ฌ์ด ์๋ฌ ์นด๋๊ฐ ๋จ๋ ๊ฒ์ ํผํ๊ธฐ ์ํจ์
๋๋ค โ
|
|
@@ -112,7 +105,6 @@ __decorate([property({
|
|
|
112
105
|
}), __decorateMetadata("design:type", Object)], UElementBlock.prototype, "loading", void 0);
|
|
113
106
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UElementBlock.prototype, "tag", void 0);
|
|
114
107
|
__decorate([property({ type: Object }), __decorateMetadata("design:type", typeof Record === "undefined" ? Object : Record)], UElementBlock.prototype, "properties", void 0);
|
|
115
|
-
__decorate([property({ type: Array }), __decorateMetadata("design:type", Array)], UElementBlock.prototype, "blacklist", void 0);
|
|
116
108
|
__decorate([state(), __decorateMetadata("design:type", Object)], UElementBlock.prototype, "element", void 0);
|
|
117
109
|
UElementBlock = __decorate([customElement("u-element-block")], UElementBlock);
|
|
118
110
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../utilities/icons.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
|
|
3
4
|
import { messages } from "../../utilities/messages.js";
|
|
@@ -13,6 +13,8 @@ import { ReferenceCitation } from '../../types/References.js';
|
|
|
13
13
|
* - ๋งํฌ๋ค์ด ๋งํฌ/์ด๋ฏธ์ง(`[..](href)`, ``, autolink)์ href/src๋
|
|
14
14
|
* `escapeHtmlHref`๋ก protocol์ ๊ฒ์ฌํฉ๋๋ค(javascript:/data:/vbscript: ์ฐจ๋จ) โ
|
|
15
15
|
* marked ์์ ์ URL์ encodeURIํ ๋ฟ protocol์ ๊ฑธ๋ฌ๋ด์ง ์์ต๋๋ค.
|
|
16
|
+
* - ์ด๋ฏธ์ง src๋ ๊ทธ ์์ ์ถ์ฒ ์ ์ฑ
(`setAllowedImagePrefixes`)์ ๊ฑฐ์นฉ๋๋ค โ ๋งํ ์ด๋ฏธ์ง๋
|
|
17
|
+
* ์์ฒญํ์ง ์๊ณ ๋์ฒด ํ
์คํธ๋ก ๊ทธ๋ฆฝ๋๋ค(์ด๋ฏธ์ง URL์ ๋ฐ์ดํฐ ๋ฐ์ถ ๊ฒฝ๋ก๋ค).
|
|
16
18
|
* - ํ
์ด๋ธ ์
์ธ๋ผ์ธ ์ฝํ
์ธ (renderTable)๋ ์ ๋ ๊ท์น๊ณผ ๊ฐ์ ๋ ๋๋ฌ ์ค์ ์ ๊ณต์ ํฉ๋๋ค
|
|
17
19
|
* โ `Parser.parseInline`์ ์ต์
์์ด ํธ์ถํ๋ฉด ๊ธฐ๋ณธ(๋น-sanitize) ๋ ๋๋ฌ๋ก ๋๋์๊ฐ๋ฏ๋ก
|
|
18
20
|
* ๋ฐ๋์ `this.parser.defaults`๋ฅผ ํจ๊ป ๋๊ฒจ์ผ ํฉ๋๋ค.
|
|
@@ -30,6 +32,7 @@ export declare class UMarkedBlock extends UElement {
|
|
|
30
32
|
private queuedTimer?;
|
|
31
33
|
private streaming;
|
|
32
34
|
private streamingTimer?;
|
|
35
|
+
connectedCallback(): void;
|
|
33
36
|
disconnectedCallback(): void;
|
|
34
37
|
protected shouldUpdate(_changedProperties: PropertyValues): boolean;
|
|
35
38
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
@@ -60,8 +63,14 @@ export declare class UMarkedBlock extends UElement {
|
|
|
60
63
|
* URL์ encodeURIํ ๋ฟ protocol์ ๊ฑธ๋ฌ๋ด์ง ์๋๋ค.
|
|
61
64
|
*/
|
|
62
65
|
private renderLink;
|
|
63
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* ๋งํฌ๋ค์ด ์ด๋ฏธ์ง์ src๋ `renderLink`์ ๋์ผํ๊ฒ protocol์ ๊ฒ์ฌํ๊ณ , ์ด๋ฏธ์ง ์ถ์ฒ ์ ์ฑ
|
|
68
|
+
* (`setAllowedImagePrefixes`)์ ๋์ด ๋ด
๋๋ค. ๋งํ ์ด๋ฏธ์ง๋ `<img>` ๋ฅผ ๋ง๋ค์ง ์๋๋ค โ
|
|
69
|
+
* ์์ฒญ ์์ฒด๊ฐ ๋ฐ์ถ ๊ฒฝ๋ก์ด๋ฏ๋ก ๋์ฒด ํ
์คํธ๋ง ๊ทธ๋ฆฐ๋ค.
|
|
70
|
+
*/
|
|
64
71
|
private renderImage;
|
|
72
|
+
/** ์ธ๋ผ์ธ ์ฝ๋ ์์ ๋จ์ด์ง ์ธ์ฉ์ ์ฝ๋ ๋ค๋ก ์ฎ๊ธด๋ค โ ์ฝ๋๋ ๊ธ์ ๊ทธ๋๋ก์ฌ์ผ ํ๋ค. */
|
|
73
|
+
private renderCodespan;
|
|
65
74
|
/**
|
|
66
75
|
* ์ธ์ฉ/์ถ์ฒ ์ฐธ์กฐ๊ฐ์ฒด๊ฐ ์์๋ ref ํ๊ทธ HTML์ this.placeholder์ ๋ณด๊ดํ๊ณ
|
|
67
76
|
* ๋งํฌ๋ค์ด ๋ฌธ์์ด์ ํด๋น ์์น์ ํ๋ ์ด์คํ๋ ์ผํฐ๋์ ์ฝ์
ํฉ๋๋ค.
|
|
@@ -4,12 +4,14 @@ import "./UCodeBlock.js";
|
|
|
4
4
|
import { escapeHtmlAttr, escapeHtmlHref, escapeHtmlText, stripZeroWidth } from "../../utilities/sanitizers.js";
|
|
5
5
|
import { HtmlBuilder } from "../../utilities/HtmlBuilder.js";
|
|
6
6
|
import { UElementBlock } from "./UElementBlock.js";
|
|
7
|
+
import { messages } from "../../utilities/messages.js";
|
|
7
8
|
import { markedKatex } from "../../utilities/markedKatex.js";
|
|
8
9
|
import "../references/URefTag.js";
|
|
9
10
|
import { URefCard } from "../references/URefCard.js";
|
|
10
11
|
import "../references/URefCardGroup.js";
|
|
11
12
|
import { UTableBlock } from "./UTableBlock.js";
|
|
12
|
-
import {
|
|
13
|
+
import { resolveImageSource } from "../../utilities/imageSources.js";
|
|
14
|
+
import { HtmlPlaceholder, extractRefPlaceholders, stripRefPlaceholders } from "../../utilities/HtmlPlaceholder.js";
|
|
13
15
|
import { styles } from "./UMarkedBlock.styles.js";
|
|
14
16
|
import { nothing } from "lit";
|
|
15
17
|
import { customElement, property, state } from "lit/decorators.js";
|
|
@@ -30,7 +32,8 @@ var UMarkedBlock = class UMarkedBlock extends UElement {
|
|
|
30
32
|
table: (token) => this.renderTable(token),
|
|
31
33
|
html: (token) => this.renderHtml(token),
|
|
32
34
|
link: (token) => this.renderLink(token),
|
|
33
|
-
image: (token) => this.renderImage(token)
|
|
35
|
+
image: (token) => this.renderImage(token),
|
|
36
|
+
codespan: (token) => this.renderCodespan(token)
|
|
34
37
|
}
|
|
35
38
|
}).use(markedKatex({ output: "mathml" }));
|
|
36
39
|
this.placeholder = new HtmlPlaceholder();
|
|
@@ -40,9 +43,15 @@ var UMarkedBlock = class UMarkedBlock extends UElement {
|
|
|
40
43
|
static {
|
|
41
44
|
this.styles = [super.styles, styles];
|
|
42
45
|
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
super.connectedCallback();
|
|
48
|
+
this.requestUpdate();
|
|
49
|
+
}
|
|
43
50
|
disconnectedCallback() {
|
|
44
51
|
clearTimeout(this.queuedTimer);
|
|
45
52
|
clearTimeout(this.streamingTimer);
|
|
53
|
+
this.queued = false;
|
|
54
|
+
this.streaming = false;
|
|
46
55
|
super.disconnectedCallback();
|
|
47
56
|
}
|
|
48
57
|
shouldUpdate(_changedProperties) {
|
|
@@ -79,7 +88,7 @@ var UMarkedBlock = class UMarkedBlock extends UElement {
|
|
|
79
88
|
*/
|
|
80
89
|
renderCode(token) {
|
|
81
90
|
const lang = token.lang ?? "plaintext";
|
|
82
|
-
if (lang === "block-json") return UElementBlock.buildHTML(token.text, { loading: this.streaming });
|
|
91
|
+
if (lang === "block-json") return UElementBlock.buildHTML(stripRefPlaceholders(token.text), { loading: this.streaming });
|
|
83
92
|
const safeText = escapeHtmlText(this.removeRefs(token.text));
|
|
84
93
|
return HtmlBuilder.build("u-code-block", { lang }, safeText);
|
|
85
94
|
}
|
|
@@ -93,12 +102,13 @@ var UMarkedBlock = class UMarkedBlock extends UElement {
|
|
|
93
102
|
* ๋ฐ๋์ `this.parser.defaults`(์ฐ๋ฆฌ ๋ ๋๋ฌ๊ฐ ๋ณํฉ๋ ์ค์ )๋ฅผ ํจ๊ป ๋๊ธด๋ค.
|
|
94
103
|
*/
|
|
95
104
|
renderTable(token) {
|
|
105
|
+
const cellHtml = (cell) => this.placeholder.restore(cell.tokens ? Parser.parseInline(cell.tokens, this.parser.defaults) : cell.text);
|
|
96
106
|
const headers = token.header.map((h) => ({
|
|
97
|
-
text:
|
|
107
|
+
text: cellHtml(h),
|
|
98
108
|
align: h.align
|
|
99
109
|
}));
|
|
100
110
|
const rows = token.rows.map((row) => row.map((cell) => ({
|
|
101
|
-
text:
|
|
111
|
+
text: cellHtml(cell),
|
|
102
112
|
align: cell.align
|
|
103
113
|
})));
|
|
104
114
|
return UTableBlock.buildHTML({
|
|
@@ -121,24 +131,44 @@ var UMarkedBlock = class UMarkedBlock extends UElement {
|
|
|
121
131
|
*/
|
|
122
132
|
renderLink(token) {
|
|
123
133
|
const text = token.tokens ? Parser.parseInline(token.tokens, this.parser.defaults) : token.text;
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
const [href, inHref] = extractRefPlaceholders(token.href);
|
|
135
|
+
const [title, inTitle] = extractRefPlaceholders(token.title ?? "");
|
|
136
|
+
let out = `<a href="${escapeHtmlHref(href)}"`;
|
|
137
|
+
if (title) out += ` title="${escapeHtmlAttr(title)}"`;
|
|
126
138
|
out += `>${text}</a>`;
|
|
127
|
-
return out;
|
|
139
|
+
return out + inHref + inTitle;
|
|
128
140
|
}
|
|
129
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* ๋งํฌ๋ค์ด ์ด๋ฏธ์ง์ src๋ `renderLink`์ ๋์ผํ๊ฒ protocol์ ๊ฒ์ฌํ๊ณ , ์ด๋ฏธ์ง ์ถ์ฒ ์ ์ฑ
|
|
143
|
+
* (`setAllowedImagePrefixes`)์ ๋์ด ๋ด
๋๋ค. ๋งํ ์ด๋ฏธ์ง๋ `<img>` ๋ฅผ ๋ง๋ค์ง ์๋๋ค โ
|
|
144
|
+
* ์์ฒญ ์์ฒด๊ฐ ๋ฐ์ถ ๊ฒฝ๋ก์ด๋ฏ๋ก ๋์ฒด ํ
์คํธ๋ง ๊ทธ๋ฆฐ๋ค.
|
|
145
|
+
*/
|
|
130
146
|
renderImage(token) {
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
const [href, inHref] = extractRefPlaceholders(token.href);
|
|
148
|
+
const [alt, inAlt] = extractRefPlaceholders(token.text);
|
|
149
|
+
const [title, inTitle] = extractRefPlaceholders(token.title ?? "");
|
|
150
|
+
const refs = inHref + inAlt + inTitle;
|
|
151
|
+
const src = resolveImageSource(href);
|
|
152
|
+
if (src === null) {
|
|
153
|
+
const label = alt ? messages.text("imageBlockedNamed", { name: alt }) : messages.text("imageBlocked");
|
|
154
|
+
return `<span class="image-blocked" part="image-blocked">${escapeHtmlText(label)}</span>` + refs;
|
|
155
|
+
}
|
|
156
|
+
let out = `<img src="${escapeHtmlAttr(src)}" alt="${escapeHtmlAttr(alt)}"`;
|
|
157
|
+
if (title) out += ` title="${escapeHtmlAttr(title)}"`;
|
|
133
158
|
out += `>`;
|
|
134
|
-
return out;
|
|
159
|
+
return out + refs;
|
|
160
|
+
}
|
|
161
|
+
/** ์ธ๋ผ์ธ ์ฝ๋ ์์ ๋จ์ด์ง ์ธ์ฉ์ ์ฝ๋ ๋ค๋ก ์ฎ๊ธด๋ค โ ์ฝ๋๋ ๊ธ์ ๊ทธ๋๋ก์ฌ์ผ ํ๋ค. */
|
|
162
|
+
renderCodespan(token) {
|
|
163
|
+
const [text, refs] = extractRefPlaceholders(token.text);
|
|
164
|
+
return `<code>${escapeHtmlText(text)}</code>${refs}`;
|
|
135
165
|
}
|
|
136
166
|
/**
|
|
137
167
|
* ์ธ์ฉ/์ถ์ฒ ์ฐธ์กฐ๊ฐ์ฒด๊ฐ ์์๋ ref ํ๊ทธ HTML์ this.placeholder์ ๋ณด๊ดํ๊ณ
|
|
138
168
|
* ๋งํฌ๋ค์ด ๋ฌธ์์ด์ ํด๋น ์์น์ ํ๋ ์ด์คํ๋ ์ผํฐ๋์ ์ฝ์
ํฉ๋๋ค.
|
|
139
169
|
*/
|
|
140
170
|
insertRefs(value, refs) {
|
|
141
|
-
const sorted =
|
|
171
|
+
const sorted = refs.filter((r) => Number.isInteger(r.endIndex) && r.endIndex >= 0 && r.endIndex <= value.length).sort((a, b) => b.endIndex - a.endIndex);
|
|
142
172
|
for (const ref of sorted) {
|
|
143
173
|
const sources = ref.sources ?? [];
|
|
144
174
|
const label = escapeHtmlText(ref.label ?? `[${refs.indexOf(ref) + 1}]`);
|
|
@@ -327,6 +327,16 @@ var styles = css`
|
|
|
327
327
|
background-color: transparent;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
/* ์ด๋ฏธ์ง ์ถ์ฒ ์ ์ฑ
์ด ๋ง์ ์๋ฆฌ โ ์์ฒญ ์์ด ๋์ฒด ํ
์คํธ๋ง ๋ณด์ธ๋ค. */
|
|
331
|
+
.image-blocked {
|
|
332
|
+
display: inline-block;
|
|
333
|
+
padding: 0 var(--base-size-4);
|
|
334
|
+
border: 1px dashed var(--borderColor-default);
|
|
335
|
+
border-radius: 6px;
|
|
336
|
+
color: var(--fgColor-muted);
|
|
337
|
+
font-size: 0.875em;
|
|
338
|
+
}
|
|
339
|
+
|
|
330
340
|
.emoji {
|
|
331
341
|
max-width: none;
|
|
332
342
|
vertical-align: text-top;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../utilities/icons.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UDataElement } from "../UDataElement.js";
|