@simple-reporting/base 1.0.8 → 1.0.9
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/dev/package.json +1 -1
- package/package.json +1 -1
- package/srl/composables/search.ts +2 -1
- package/srl/types/nswow.d.ts +3 -0
- package/srl/utils/html.ts +9 -2
package/dev/package.json
CHANGED
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
*/
|
|
39
39
|
import { computed, type ComputedRef, ref } from 'vue';
|
|
40
40
|
import { HTMLElement, parse as parseHtml } from 'node-html-parser';
|
|
41
|
+
import { useConfig, useArticles } from '#composables';
|
|
41
42
|
|
|
42
43
|
const storage = ref<{
|
|
43
44
|
[locale: string]: NsWowSearchList[];
|
|
@@ -68,7 +69,7 @@ function makeWords(html: string) {
|
|
|
68
69
|
.replace(/\s{2,}/g, ' ');
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
export default async function useSearch(): ComputedRef<NsWowSearchList[]
|
|
72
|
+
export default async function useSearch(): Promise<ComputedRef<NsWowSearchList[]>> {
|
|
72
73
|
const config = useConfig();
|
|
73
74
|
if (!storage.value || !storage.value[config.value.locale]) {
|
|
74
75
|
!storage.value ? (storage.value = {}) : null;
|
package/srl/types/nswow.d.ts
CHANGED
package/srl/utils/html.ts
CHANGED
|
@@ -7,6 +7,8 @@ function attributesToString(attributes: Record<string, string | null>): string {
|
|
|
7
7
|
.join(' ');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
type AttrObj = { [key: string]: string | null };
|
|
11
|
+
|
|
10
12
|
export function prepareHtmlContent(text: string): string {
|
|
11
13
|
const articles = useArticles();
|
|
12
14
|
const locale = useLocale();
|
|
@@ -14,8 +16,8 @@ export function prepareHtmlContent(text: string): string {
|
|
|
14
16
|
const regex = /<a\s+([^>]+)>(.*?)<\/a>/gis;
|
|
15
17
|
text = text.replace(regex, (match, attrString, innerText) => {
|
|
16
18
|
// Attribute in ein Array umwandeln
|
|
17
|
-
const attrObj = {};
|
|
18
|
-
attrString.replace(/([a-zA-Z0-9\-_]+)(?:="([^"]*)")?/g, (m, key, value) => {
|
|
19
|
+
const attrObj: AttrObj = {};
|
|
20
|
+
attrString.replace(/([a-zA-Z0-9\-_]+)(?:="([^"]*)")?/g, (m, key: string, value: string | null) => {
|
|
19
21
|
attrObj[key] = value || null;
|
|
20
22
|
return m;
|
|
21
23
|
});
|
|
@@ -66,6 +68,11 @@ export function prepareHtmlContent(text: string): string {
|
|
|
66
68
|
return match;
|
|
67
69
|
});
|
|
68
70
|
|
|
71
|
+
text = text.replace(
|
|
72
|
+
/<template-([a-z]+)>([\s\S]*?)<\/template-\1>/g,
|
|
73
|
+
(_match, name, content) => `<template #${name}>${content}</template>`
|
|
74
|
+
);
|
|
75
|
+
|
|
69
76
|
text = text.replaceAll('../', `./`);
|
|
70
77
|
|
|
71
78
|
text = text.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, (match, p1) => {
|