@simple-reporting/base 1.0.8 → 1.0.10
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 +2 -2
- package/package.json +1 -1
- package/srl/components/Srl/Note/Accordion/Content.vue +12 -0
- package/srl/components/Srl/Note/Accordion/Toggle.vue +13 -0
- package/srl/components/Srl/Note/Accordion.vue +17 -0
- package/srl/composables/search.ts +2 -1
- package/srl/plugins/vueSrlPlugin.ts +7 -0
- package/srl/types/nswow.d.ts +3 -0
- package/srl/utils/html.ts +109 -2
package/dev/package.json
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"type-check": "vue-tsc --build",
|
|
17
17
|
"lint": "eslint . --fix",
|
|
18
18
|
"format": "prettier --write src/",
|
|
19
|
-
"postinstall": "srl prepare"
|
|
19
|
+
"postinstall": "npx srl prepare"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@simple-reporting/base": "^1.0.
|
|
22
|
+
"@simple-reporting/base": "^1.0.10",
|
|
23
23
|
"axios": "^1.9.0",
|
|
24
24
|
"chalk": "^5.4.1",
|
|
25
25
|
"exceljs": "^4.4.0",
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
id: string
|
|
4
|
+
open: boolean
|
|
5
|
+
toggle: () => void
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<button @click="props.toggle()" :aria-expanded="props.open" :aria-controls="props.id">
|
|
11
|
+
<slot/>
|
|
12
|
+
</button>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, useId } from 'vue'
|
|
3
|
+
|
|
4
|
+
const id = ref(useId())
|
|
5
|
+
const accordion = ref<HTMLDivElement>()
|
|
6
|
+
const open = ref(false)
|
|
7
|
+
|
|
8
|
+
function toggle() {
|
|
9
|
+
open.value = !open.value
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div ref="accordion">
|
|
15
|
+
<slot :id="id" :open="open" :toggle="toggle"/>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -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;
|
|
@@ -5,6 +5,10 @@ import SrlArticleRoot from '#components/Srl/Article/Root.vue';
|
|
|
5
5
|
import SrlArticleDialogButton from '#components/Srl/Article/DialogButton.vue';
|
|
6
6
|
import SrlMenu from '#components/Srl/Menu/List.vue';
|
|
7
7
|
import SrlPageDialog from '#components/Srl/Page/Dialog.vue';
|
|
8
|
+
import SrlNoteAccordion from '#components/Srl/Note/Accordion.vue';
|
|
9
|
+
import SrlNoteAccordionToggle from '#components/Srl/Note/Accordion/Toggle.vue';
|
|
10
|
+
import SrlNoteAccordionContent from '#components/Srl/Note/Accordion/Content.vue';
|
|
11
|
+
|
|
8
12
|
import asyncLdComponent from './asyncLdComponent.ts';
|
|
9
13
|
|
|
10
14
|
export default {
|
|
@@ -12,6 +16,9 @@ export default {
|
|
|
12
16
|
app.component('SrlAriaTabChain', defineComponent(SrlAriaTabChain));
|
|
13
17
|
app.component('SrlArticleAutoload', defineComponent(SrlArticleAutoload));
|
|
14
18
|
app.component('SrlArticleRoot', defineComponent(SrlArticleRoot));
|
|
19
|
+
app.component('SrlNoteAccordion', defineComponent(SrlNoteAccordion));
|
|
20
|
+
app.component('SrlNoteAccordionToggle', defineComponent(SrlNoteAccordionToggle));
|
|
21
|
+
app.component('SrlNoteAccordionContent', defineComponent(SrlNoteAccordionContent));
|
|
15
22
|
app.component(
|
|
16
23
|
'SrlArticleDialogButton',
|
|
17
24
|
defineComponent(SrlArticleDialogButton),
|
package/srl/types/nswow.d.ts
CHANGED
package/srl/utils/html.ts
CHANGED
|
@@ -1,12 +1,110 @@
|
|
|
1
1
|
import { isRouterPath } from '#utils/uri.ts';
|
|
2
2
|
import { useArticles, useLocale, addCssStyles } from '#composables';
|
|
3
3
|
|
|
4
|
+
type AttrObj = { [key: string]: string | null };
|
|
4
5
|
function attributesToString(attributes: Record<string, string | null>): string {
|
|
5
6
|
return Object.entries(attributes)
|
|
6
7
|
.map(([key, value]) => (value !== null ? `${key}="${value}"` : key))
|
|
7
8
|
.join(' ');
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
function replaceAccordionContainer(text: string): string {
|
|
12
|
+
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion\s[^"']*["'][^>]*)>/gi;
|
|
13
|
+
let result = '';
|
|
14
|
+
let lastIndex = 0;
|
|
15
|
+
let match;
|
|
16
|
+
|
|
17
|
+
while ((match = openTagRegex.exec(text)) !== null) {
|
|
18
|
+
const start = match.index;
|
|
19
|
+
const attrs = match[1];
|
|
20
|
+
let depth = 1;
|
|
21
|
+
let end = openTagRegex.lastIndex;
|
|
22
|
+
|
|
23
|
+
while (depth > 0) {
|
|
24
|
+
const nextOpen = text.indexOf('<div', end);
|
|
25
|
+
const nextClose = text.indexOf('</div>', end);
|
|
26
|
+
if (nextClose === -1) break;
|
|
27
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
28
|
+
depth++;
|
|
29
|
+
end = nextOpen + 4;
|
|
30
|
+
} else {
|
|
31
|
+
depth--;
|
|
32
|
+
end = nextClose + 6;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const innerContent = replaceAccordionContainer(text.slice(openTagRegex.lastIndex, end - 6));
|
|
37
|
+
|
|
38
|
+
result += text.slice(lastIndex, start);
|
|
39
|
+
result += `<srl-note-accordion${attrs}>${innerContent}</srl-note-accordion>`;
|
|
40
|
+
lastIndex = end;
|
|
41
|
+
openTagRegex.lastIndex = end;
|
|
42
|
+
}
|
|
43
|
+
result += text.slice(lastIndex);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function replaceAccordionToggle(text: string): string {
|
|
48
|
+
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion__head\s[^"']*["'][^>]*)>/gi;
|
|
49
|
+
let result = '';
|
|
50
|
+
let lastIndex = 0;
|
|
51
|
+
let match;
|
|
52
|
+
|
|
53
|
+
while ((match = openTagRegex.exec(text)) !== null) {
|
|
54
|
+
const start = match.index;
|
|
55
|
+
const attrs = match[1];
|
|
56
|
+
const contentStart = openTagRegex.lastIndex;
|
|
57
|
+
const closeTag = '</div>';
|
|
58
|
+
const end = text.indexOf(closeTag, contentStart);
|
|
59
|
+
if (end === -1) break;
|
|
60
|
+
|
|
61
|
+
const innerContent = text.slice(contentStart, end);
|
|
62
|
+
|
|
63
|
+
result += text.slice(lastIndex, start);
|
|
64
|
+
result += `<srl-note-accordion-toggle${attrs}>${innerContent}</srl-note-accordion-toggle>`;
|
|
65
|
+
lastIndex = end + closeTag.length;
|
|
66
|
+
openTagRegex.lastIndex = lastIndex;
|
|
67
|
+
}
|
|
68
|
+
result += text.slice(lastIndex);
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function replaceAccordionContent(text: string): string {
|
|
73
|
+
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion__content(?:\s[^"']*)?["'][^>]*)>/gi;
|
|
74
|
+
let result = '';
|
|
75
|
+
let lastIndex = 0;
|
|
76
|
+
let match;
|
|
77
|
+
|
|
78
|
+
while ((match = openTagRegex.exec(text)) !== null) {
|
|
79
|
+
const start = match.index;
|
|
80
|
+
const attrs = match[1];
|
|
81
|
+
let depth = 1;
|
|
82
|
+
let end = openTagRegex.lastIndex;
|
|
83
|
+
|
|
84
|
+
while (depth > 0) {
|
|
85
|
+
const nextOpen = text.indexOf('<div', end);
|
|
86
|
+
const nextClose = text.indexOf('</div>', end);
|
|
87
|
+
if (nextClose === -1) break;
|
|
88
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
89
|
+
depth++;
|
|
90
|
+
end = nextOpen + 4;
|
|
91
|
+
} else {
|
|
92
|
+
depth--;
|
|
93
|
+
end = nextClose + 6;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const innerContent = replaceAccordionContent(text.slice(openTagRegex.lastIndex, end - 6));
|
|
98
|
+
|
|
99
|
+
result += text.slice(lastIndex, start);
|
|
100
|
+
result += `<srl-note-accordion-content${attrs}>${innerContent}</srl-note-accordion-content>`;
|
|
101
|
+
lastIndex = end;
|
|
102
|
+
openTagRegex.lastIndex = end;
|
|
103
|
+
}
|
|
104
|
+
result += text.slice(lastIndex);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
|
|
10
108
|
export function prepareHtmlContent(text: string): string {
|
|
11
109
|
const articles = useArticles();
|
|
12
110
|
const locale = useLocale();
|
|
@@ -14,8 +112,8 @@ export function prepareHtmlContent(text: string): string {
|
|
|
14
112
|
const regex = /<a\s+([^>]+)>(.*?)<\/a>/gis;
|
|
15
113
|
text = text.replace(regex, (match, attrString, innerText) => {
|
|
16
114
|
// Attribute in ein Array umwandeln
|
|
17
|
-
const attrObj = {};
|
|
18
|
-
attrString.replace(/([a-zA-Z0-9\-_]+)(?:="([^"]*)")?/g, (m, key, value) => {
|
|
115
|
+
const attrObj: AttrObj = {};
|
|
116
|
+
attrString.replace(/([a-zA-Z0-9\-_]+)(?:="([^"]*)")?/g, (m, key: string, value: string | null) => {
|
|
19
117
|
attrObj[key] = value || null;
|
|
20
118
|
return m;
|
|
21
119
|
});
|
|
@@ -66,6 +164,15 @@ export function prepareHtmlContent(text: string): string {
|
|
|
66
164
|
return match;
|
|
67
165
|
});
|
|
68
166
|
|
|
167
|
+
text = text.replace(
|
|
168
|
+
/<template-([a-z]+)>([\s\S]*?)<\/template-\1>/g,
|
|
169
|
+
(_match, name, content) => `<template #${name}>${content}</template>`
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
text = replaceAccordionContainer(text)
|
|
173
|
+
text = replaceAccordionToggle(text)
|
|
174
|
+
text = replaceAccordionContent(text)
|
|
175
|
+
|
|
69
176
|
text = text.replaceAll('../', `./`);
|
|
70
177
|
|
|
71
178
|
text = text.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, (match, p1) => {
|