@rt-tools/ui-kit-v2 0.34.5 → 0.35.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/fesm2022/rt-tools-ui-kit-v2-ai-prompt-input.mjs +574 -0
- package/fesm2022/rt-tools-ui-kit-v2-ai-prompt-input.mjs.map +1 -0
- package/fesm2022/rt-tools-ui-kit-v2-core.mjs +62 -3
- package/fesm2022/rt-tools-ui-kit-v2-core.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-markdown-text.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-markdown-text.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-rich-editor.mjs +128 -20
- package/fesm2022/rt-tools-ui-kit-v2-rich-editor.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-thread-list.mjs +2 -2
- package/fesm2022/rt-tools-ui-kit-v2-thread-list.mjs.map +1 -1
- package/fesm2022/rt-tools-ui-kit-v2-usage-ring.mjs +163 -0
- package/fesm2022/rt-tools-ui-kit-v2-usage-ring.mjs.map +1 -0
- package/fesm2022/rt-tools-ui-kit-v2.mjs +2 -0
- package/package.json +9 -1
- package/src/lib/components/ai-prompt-input/CONTEXT.md +60 -0
- package/src/lib/components/ai-prompt-input/rt-ai-prompt-input.component.scss +113 -0
- package/src/lib/components/markdown-text/rt-markdown-text.component.scss +3 -0
- package/src/lib/components/thread-list/rt-thread-list.component.scss +19 -11
- package/src/lib/components/usage-ring/CONTEXT.md +33 -0
- package/src/lib/components/usage-ring/rt-usage-ring.component.scss +64 -0
- package/src/rich-editor/lib/components/ai-chat/CONTEXT.md +1 -1
- package/src/rich-editor/lib/components/ai-chat/answer/rt-ai-chat-answer.component.scss +1 -0
- package/src/rich-editor/lib/components/ai-chat/rt-ai-chat.component.scss +6 -0
- package/types/rt-tools-ui-kit-v2-ai-prompt-input.d.ts +193 -0
- package/types/rt-tools-ui-kit-v2-core.d.ts +4 -0
- package/types/rt-tools-ui-kit-v2-rich-editor.d.ts +49 -3
- package/types/rt-tools-ui-kit-v2-usage-ring.d.ts +47 -0
- package/types/rt-tools-ui-kit-v2.d.ts +2 -0
|
@@ -40,12 +40,16 @@ const RT_KIT_LABELS_EN = {
|
|
|
40
40
|
aiLike: "Good answer",
|
|
41
41
|
aiNewThread: "New conversation",
|
|
42
42
|
aiNoThreads: "No conversations yet",
|
|
43
|
+
aiPromptEffortAria: "Effort",
|
|
44
|
+
aiPromptModeAria: "Mode",
|
|
45
|
+
aiPromptModelAria: "Model",
|
|
43
46
|
aiReference: "Reference",
|
|
44
47
|
aiRetry: "Ask again",
|
|
45
48
|
aiSearchThreads: "Search conversations",
|
|
46
49
|
aiShowSteps: "Show steps",
|
|
47
50
|
aiThreads: "Conversations",
|
|
48
51
|
aiTitle: "Assistant",
|
|
52
|
+
aiUsageAria: "Used {{percent}}% of the limit",
|
|
49
53
|
aiYou: "You",
|
|
50
54
|
asideCopyErrorInfo: "Copy error info",
|
|
51
55
|
asideRequestError: "Request Error",
|
|
@@ -2006,6 +2010,21 @@ const ALLOWED_SCHEMES = [
|
|
|
2006
2010
|
"https://",
|
|
2007
2011
|
"mailto:"
|
|
2008
2012
|
];
|
|
2013
|
+
const BARE_SCHEMES = ["http://", "https://"];
|
|
2014
|
+
const TRAILING_PUNCTUATION = /* @__PURE__ */ new Set([
|
|
2015
|
+
".",
|
|
2016
|
+
",",
|
|
2017
|
+
";",
|
|
2018
|
+
":",
|
|
2019
|
+
"!",
|
|
2020
|
+
"?",
|
|
2021
|
+
"'",
|
|
2022
|
+
"\"",
|
|
2023
|
+
"»",
|
|
2024
|
+
")",
|
|
2025
|
+
"]"
|
|
2026
|
+
]);
|
|
2027
|
+
const WORD_CHAR = /[\p{L}\p{N}]/u;
|
|
2009
2028
|
const PAIRED_MARKS = [
|
|
2010
2029
|
{
|
|
2011
2030
|
mark: "`",
|
|
@@ -2058,6 +2077,39 @@ function isAllowedHref(value) {
|
|
|
2058
2077
|
const lowered = value.toLowerCase();
|
|
2059
2078
|
return ALLOWED_SCHEMES.some((scheme) => lowered.startsWith(scheme));
|
|
2060
2079
|
}
|
|
2080
|
+
function isWordChar(source, index) {
|
|
2081
|
+
return index >= 0 && index < source.length && WORD_CHAR.test(source[index]);
|
|
2082
|
+
}
|
|
2083
|
+
function unlink(nodes) {
|
|
2084
|
+
return nodes.flatMap((node) => node.kind === ERtMarkdownInline.Link ? unlink(node.children) : [{
|
|
2085
|
+
...node,
|
|
2086
|
+
children: unlink(node.children)
|
|
2087
|
+
}]);
|
|
2088
|
+
}
|
|
2089
|
+
function countOf(value, sign) {
|
|
2090
|
+
return value.split(sign).length - 1;
|
|
2091
|
+
}
|
|
2092
|
+
function readBareUrl(source, start) {
|
|
2093
|
+
if (source[start]?.toLowerCase() !== "h" || isWordChar(source, start - 1)) return null;
|
|
2094
|
+
const rest = source.slice(start);
|
|
2095
|
+
const lowered = rest.toLowerCase();
|
|
2096
|
+
const scheme = BARE_SCHEMES.find((candidate) => lowered.startsWith(candidate));
|
|
2097
|
+
if (scheme === void 0) return null;
|
|
2098
|
+
const whole = rest.split(/\s/u, 1)[0];
|
|
2099
|
+
let address = whole;
|
|
2100
|
+
while (address.length > 0 && TRAILING_PUNCTUATION.has(address[address.length - 1])) address = address.slice(0, -1);
|
|
2101
|
+
while (address.length < whole.length && whole[address.length] === ")" && countOf(address, "(") > countOf(address, ")")) address += ")";
|
|
2102
|
+
if (address.length <= scheme.length) return null;
|
|
2103
|
+
return {
|
|
2104
|
+
length: address.length,
|
|
2105
|
+
node: {
|
|
2106
|
+
kind: ERtMarkdownInline.Link,
|
|
2107
|
+
text: address,
|
|
2108
|
+
children: [textNode(address)],
|
|
2109
|
+
href: address
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2061
2113
|
function readImage(source, start) {
|
|
2062
2114
|
if (source[start] !== "!" || source[start + 1] !== "[") return null;
|
|
2063
2115
|
const close = source.indexOf("]", start + 2);
|
|
@@ -2082,16 +2134,23 @@ function readLink(source, start, nested) {
|
|
|
2082
2134
|
node: {
|
|
2083
2135
|
kind: ERtMarkdownInline.Link,
|
|
2084
2136
|
text: label,
|
|
2085
|
-
children: nested(label),
|
|
2137
|
+
children: unlink(nested(label)),
|
|
2086
2138
|
href: address
|
|
2087
2139
|
}
|
|
2088
2140
|
};
|
|
2089
2141
|
}
|
|
2142
|
+
function findClose(source, mark, from, intraword) {
|
|
2143
|
+
let close = source.indexOf(mark, from);
|
|
2144
|
+
while (intraword && close !== -1 && isWordChar(source, close + mark.length)) close = source.indexOf(mark, close + 1);
|
|
2145
|
+
return close;
|
|
2146
|
+
}
|
|
2090
2147
|
function readPaired(source, start, nested) {
|
|
2091
2148
|
const pair = PAIRED_MARKS.find((candidate) => source.startsWith(candidate.mark, start));
|
|
2092
2149
|
if (pair === void 0) return null;
|
|
2150
|
+
const intraword = pair.mark.startsWith("_");
|
|
2151
|
+
if (intraword && isWordChar(source, start - 1)) return null;
|
|
2093
2152
|
const from = start + pair.mark.length;
|
|
2094
|
-
const close = source
|
|
2153
|
+
const close = findClose(source, pair.mark, from, intraword);
|
|
2095
2154
|
if (close === -1 || close === from) return null;
|
|
2096
2155
|
const inner = source.slice(from, close);
|
|
2097
2156
|
return {
|
|
@@ -2105,7 +2164,7 @@ function readPaired(source, start, nested) {
|
|
|
2105
2164
|
};
|
|
2106
2165
|
}
|
|
2107
2166
|
function readAt(source, index, nested) {
|
|
2108
|
-
return readImage(source, index) ?? readLink(source, index, nested) ?? readPaired(source, index, nested) ?? {
|
|
2167
|
+
return readImage(source, index) ?? readLink(source, index, nested) ?? readBareUrl(source, index) ?? readPaired(source, index, nested) ?? {
|
|
2109
2168
|
length: 1,
|
|
2110
2169
|
node: null
|
|
2111
2170
|
};
|