adb-shared 6.2.21 → 6.2.25
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/{adb-shared-src-map.mjs → adb-shared-map.mjs} +97 -44
- package/fesm2022/adb-shared-map.mjs.map +1 -0
- package/fesm2022/adb-shared.mjs +67 -61
- package/fesm2022/adb-shared.mjs.map +1 -1
- package/package.json +4 -4
- package/types/{adb-shared-src-map.d.ts → adb-shared-map.d.ts} +6 -1
- package/fesm2022/adb-shared-src-map.mjs.map +0 -1
package/fesm2022/adb-shared.mjs
CHANGED
|
@@ -1912,8 +1912,10 @@ class AdbRichEditorComponent {
|
|
|
1912
1912
|
value.slice(start);
|
|
1913
1913
|
this.updateValue(newValue);
|
|
1914
1914
|
const cursor = start + marker.length;
|
|
1915
|
-
|
|
1916
|
-
|
|
1915
|
+
requestAnimationFrame(() => {
|
|
1916
|
+
textarea.focus();
|
|
1917
|
+
textarea.setSelectionRange(cursorStart, cursorEnd);
|
|
1918
|
+
});
|
|
1917
1919
|
return;
|
|
1918
1920
|
}
|
|
1919
1921
|
const existingMarker = this.findWrappingMarker(value, start, end, FORMAT_MARKERS[type]);
|
|
@@ -1934,8 +1936,10 @@ class AdbRichEditorComponent {
|
|
|
1934
1936
|
const cursorEnd = existingMarker
|
|
1935
1937
|
? end - marker.length
|
|
1936
1938
|
: end + marker.length;
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
+
requestAnimationFrame(() => {
|
|
1940
|
+
textarea.focus();
|
|
1941
|
+
textarea.setSelectionRange(cursorStart, cursorEnd);
|
|
1942
|
+
});
|
|
1939
1943
|
}
|
|
1940
1944
|
findWrappingMarker(value, start, end, markers) {
|
|
1941
1945
|
return (markers.find(marker => value.substring(start - marker.length, start) === marker &&
|
|
@@ -2041,76 +2045,78 @@ class RichTextComponent {
|
|
|
2041
2045
|
}
|
|
2042
2046
|
parseCustomMarkdown(input) {
|
|
2043
2047
|
const parts = [];
|
|
2044
|
-
|
|
2045
|
-
const
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
const referenceRegex = /\[([^\]]+)\]\(reference:([^)]+)\)/g;
|
|
2049
|
-
const combinedRegex = new RegExp([
|
|
2050
|
-
boldRegex.source,
|
|
2051
|
-
italicRegex.source,
|
|
2052
|
-
taxonRegex.source,
|
|
2053
|
-
termRegex.source,
|
|
2054
|
-
referenceRegex.source
|
|
2055
|
-
].join('|'), 'g');
|
|
2056
|
-
let lastIndex = 0;
|
|
2057
|
-
let match;
|
|
2058
|
-
while ((match = combinedRegex.exec(input)) !== null) {
|
|
2059
|
-
if (match.index > lastIndex) {
|
|
2060
|
-
parts.push({
|
|
2061
|
-
type: 'text',
|
|
2062
|
-
content: input.slice(lastIndex, match.index)
|
|
2063
|
-
});
|
|
2048
|
+
let i = 0;
|
|
2049
|
+
const pushText = (text) => {
|
|
2050
|
+
if (text) {
|
|
2051
|
+
parts.push({ type: 'text', content: text });
|
|
2064
2052
|
}
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2053
|
+
};
|
|
2054
|
+
while (i < input.length) {
|
|
2055
|
+
if (input.startsWith('**', i) || input.startsWith('__', i)) {
|
|
2056
|
+
const marker = input.substr(i, 2);
|
|
2057
|
+
const end = input.indexOf(marker, i + 2);
|
|
2058
|
+
if (end !== -1) {
|
|
2059
|
+
parts.push({
|
|
2060
|
+
type: 'bold',
|
|
2061
|
+
content: input.slice(i + 2, end)
|
|
2062
|
+
});
|
|
2063
|
+
i = end + 2;
|
|
2064
|
+
continue;
|
|
2065
|
+
}
|
|
2070
2066
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2067
|
+
if (input[i] === '*' || input[i] === '_') {
|
|
2068
|
+
const marker = input[i];
|
|
2069
|
+
const end = input.indexOf(marker, i + 1);
|
|
2070
|
+
if (end !== -1) {
|
|
2071
|
+
parts.push({
|
|
2072
|
+
type: 'italic',
|
|
2073
|
+
content: input.slice(i + 1, end)
|
|
2074
|
+
});
|
|
2075
|
+
i = end + 1;
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2076
2078
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2079
|
+
if (input[i] === '[') {
|
|
2080
|
+
const textEnd = input.indexOf(']', i);
|
|
2081
|
+
const linkStart = input.indexOf('(', textEnd);
|
|
2082
|
+
const linkEnd = input.indexOf(')', linkStart);
|
|
2083
|
+
if (textEnd !== -1 && linkStart !== -1 && linkEnd !== -1) {
|
|
2084
|
+
const label = input.slice(i + 1, textEnd);
|
|
2085
|
+
const link = input.slice(linkStart + 1, linkEnd);
|
|
2086
|
+
const [type, id] = link.split(':');
|
|
2087
|
+
if (type === 'taxon' || type === 'term' || type === 'reference') {
|
|
2088
|
+
parts.push({
|
|
2089
|
+
type: type,
|
|
2090
|
+
content: label,
|
|
2091
|
+
id
|
|
2092
|
+
});
|
|
2093
|
+
i = linkEnd + 1;
|
|
2094
|
+
continue;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2083
2097
|
}
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
}
|
|
2098
|
+
let next = input.length;
|
|
2099
|
+
for (const c of ['*', '_', '[']) {
|
|
2100
|
+
const idx = input.indexOf(c, i + 1);
|
|
2101
|
+
if (idx !== -1 && idx < next) {
|
|
2102
|
+
next = idx;
|
|
2103
|
+
}
|
|
2090
2104
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
content: match[9],
|
|
2095
|
-
id: match[10]
|
|
2096
|
-
});
|
|
2105
|
+
if (next === input.length) {
|
|
2106
|
+
pushText(input.slice(i));
|
|
2107
|
+
break;
|
|
2097
2108
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
if (lastIndex < input.length) {
|
|
2101
|
-
parts.push({
|
|
2102
|
-
type: 'text',
|
|
2103
|
-
content: input.slice(lastIndex)
|
|
2104
|
-
});
|
|
2109
|
+
pushText(input.slice(i, next));
|
|
2110
|
+
i = next;
|
|
2105
2111
|
}
|
|
2106
2112
|
return parts;
|
|
2107
2113
|
}
|
|
2108
2114
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: RichTextComponent, deps: [{ token: RICH_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
|
|
2109
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: RichTextComponent, isStandalone: false, selector: "adb-rich-text", inputs: { text: "text" }, usesOnChanges: true, ngImport: i0, template: "<div style=\"white-space: pre-wrap;\">\r\n @for (part of parts; track
|
|
2115
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: RichTextComponent, isStandalone: false, selector: "adb-rich-text", inputs: { text: "text" }, usesOnChanges: true, ngImport: i0, template: "<div style=\"white-space: pre-wrap;\">\r\n @for (part of parts; track $index) {\r\n @switch (part.type) {\r\n @case ('text') { <span>{{ part.content }}</span> }\r\n @case ('italic') { <em>{{ part.content }}</em> }\r\n @case ('bold') { <b>{{ part.content }}</b> }\r\n @case ('taxon') { <a [href]=\"taxonUrl + part.id\">{{ part.content }}</a> }\r\n @default { <span>{{ part.content }}</span> }\r\n }\r\n}\r\n</div>" });
|
|
2110
2116
|
}
|
|
2111
2117
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: RichTextComponent, decorators: [{
|
|
2112
2118
|
type: Component,
|
|
2113
|
-
args: [{ selector: 'adb-rich-text', standalone: false, template: "<div style=\"white-space: pre-wrap;\">\r\n @for (part of parts; track
|
|
2119
|
+
args: [{ selector: 'adb-rich-text', standalone: false, template: "<div style=\"white-space: pre-wrap;\">\r\n @for (part of parts; track $index) {\r\n @switch (part.type) {\r\n @case ('text') { <span>{{ part.content }}</span> }\r\n @case ('italic') { <em>{{ part.content }}</em> }\r\n @case ('bold') { <b>{{ part.content }}</b> }\r\n @case ('taxon') { <a [href]=\"taxonUrl + part.id\">{{ part.content }}</a> }\r\n @default { <span>{{ part.content }}</span> }\r\n }\r\n}\r\n</div>" }]
|
|
2114
2120
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2115
2121
|
type: Inject,
|
|
2116
2122
|
args: [RICH_MODULE_CONFIG]
|