@keycloakify/svelte 0.1.0 → 0.1.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.
|
@@ -10,7 +10,19 @@ export function createUseI18n(params) {
|
|
|
10
10
|
function renderHtmlString(params) {
|
|
11
11
|
const { htmlString, msgKey } = params;
|
|
12
12
|
return createRawSnippet(() => ({
|
|
13
|
-
render: () =>
|
|
13
|
+
render: () => {
|
|
14
|
+
const elementName = (() => {
|
|
15
|
+
if (htmlString.includes('<') && htmlString.includes('>')) {
|
|
16
|
+
for (const tagName of ['div', 'section', 'article', 'ul', 'ol']) {
|
|
17
|
+
if (htmlString.includes(`<${tagName}`)) {
|
|
18
|
+
return 'div';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return 'span';
|
|
23
|
+
})();
|
|
24
|
+
return `<${elementName} data-kc-msg="${msgKey}">${htmlString}</${elementName}>`;
|
|
25
|
+
},
|
|
14
26
|
}));
|
|
15
27
|
}
|
|
16
28
|
function withSvelte(i18n_noJsx) {
|
|
@@ -39,7 +51,7 @@ export function createUseI18n(params) {
|
|
|
39
51
|
}
|
|
40
52
|
const styleElement = document.createElement('style');
|
|
41
53
|
styleElement.attributes.setNamedItem(document.createAttribute(attributeName));
|
|
42
|
-
styleElement.textContent = `[
|
|
54
|
+
styleElement.textContent = `div[${attributeName}] { display: inline-block; }`;
|
|
43
55
|
document.head.prepend(styleElement);
|
|
44
56
|
}
|
|
45
57
|
const { getI18n } = createGetI18n({ extraLanguageTranslations, messagesByLanguageTag_themeDefined });
|
package/package.json
CHANGED
|
@@ -64,7 +64,20 @@ export function createUseI18n<
|
|
|
64
64
|
function renderHtmlString(params: { htmlString: string; msgKey: string }): Snippet {
|
|
65
65
|
const { htmlString, msgKey } = params;
|
|
66
66
|
return createRawSnippet(() => ({
|
|
67
|
-
render: () =>
|
|
67
|
+
render: () => {
|
|
68
|
+
const elementName = (() => {
|
|
69
|
+
if (htmlString.includes('<') && htmlString.includes('>')) {
|
|
70
|
+
for (const tagName of ['div', 'section', 'article', 'ul', 'ol']) {
|
|
71
|
+
if (htmlString.includes(`<${tagName}`)) {
|
|
72
|
+
return 'div';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return 'span';
|
|
77
|
+
})();
|
|
78
|
+
|
|
79
|
+
return `<${elementName} data-kc-msg="${msgKey}">${htmlString}</${elementName}>`;
|
|
80
|
+
},
|
|
68
81
|
}));
|
|
69
82
|
}
|
|
70
83
|
|
|
@@ -104,7 +117,7 @@ export function createUseI18n<
|
|
|
104
117
|
|
|
105
118
|
const styleElement = document.createElement('style');
|
|
106
119
|
styleElement.attributes.setNamedItem(document.createAttribute(attributeName));
|
|
107
|
-
styleElement.textContent = `[
|
|
120
|
+
styleElement.textContent = `div[${attributeName}] { display: inline-block; }`;
|
|
108
121
|
document.head.prepend(styleElement);
|
|
109
122
|
}
|
|
110
123
|
|